osfp中发布静态路由

拓扑图如下:




配置如下:
R1#sh running-config
Building configuration…

Current configuration:
!
version 12.1
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname R1
!
!
!
!
!
!
memory-size iomem 15
ip subnet-zero
!
!
!
!
interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface Loopback1
ip address 3.3.3.3 255.255.255.0
!
interface FastEthernet0/0
no ip address
shutdown
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 192.168.1.1 255.255.255.0
duplex auto
speed auto
!
router ospf 1
log-adjacency-changes
redistribute static subnets
!
ip classless
ip route 2.2.2.0 255.255.255.0 192.168.1.2
ip route 4.4.4.0 255.255.255.0 192.168.1.2
ip route 172.16.0.0 255.255.0.0 192.168.1.2
no ip http server
!
!
line con 0
transport input none
line aux 0
line vty 0 4
login
!
end



R2#sh running-config
Building configuration…

Current configuration:
!
version 12.1
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname R2
!
!
!
!
!
!
memory-size iomem 15
ip subnet-zero
!
!
!
!
interface Ethernet1/0
ip address 192.168.1.2 255.255.255.0
!
interface Ethernet1/1
ip address 172.16.1.1 255.255.0.0
!
interface Ethernet1/2
no ip address
shutdown
!
interface Ethernet1/3
no ip address
shutdown
!
router ospf 1
log-adjacency-changes
redistribute static subnets
network 172.16.0.0 0.0.255.255 area 0
network 192.168.1.0 0.0.0.255 area 0

!
ip classless
ip route 1.1.1.0 255.255.255.0 192.168.1.1
ip route 3.3.3.0 255.255.255.0 192.168.1.1
no ip http server
!
!
line con 0
transport input none
line aux 0
line vty 0 4
login
!
end



R3#sh running-config
Building configuration…

Current configuration:
!
version 12.1
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname R3
!
!
!
!
!
!
memory-size iomem 15
ip subnet-zero
!
!
!
!
interface Loopback0
ip address 2.2.2.2 255.255.255.0
!
interface Loopback2
ip address 4.4.4.4 255.255.255.0
!
interface Ethernet1/0
ip address 172.16.1.2 255.255.0.0
!
interface Ethernet1/1
no ip address
shutdown
!
interface Ethernet1/2
no ip address
shutdown
!
interface Ethernet1/3
no ip address
shutdown
!
router ospf 1
log-adjacency-changes
network 2.2.2.0 0.0.0.255 area 2
network 4.4.4.0 0.0.0.255 area 3
network 172.16.0.0 0.0.255.255 area 0
!
ip classless
no ip http server
!
!
line con 0
transport input none
line aux 0
line vty 0 4
login
!
end

路由表显示

R1#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route

Gateway of last resort is not set

1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
2.0.0.0/24 is subnetted, 1 subnets
S       2.2.2.0 [1/0] via 192.168.1.2
3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback1
4.0.0.0/24 is subnetted, 1 subnets
S       4.4.4.0 [1/0] via 192.168.1.2
S    172.16.0.0/16 [1/0] via 192.168.1.2
C    192.168.1.0/24 is directly connected, FastEthernet0/1



R2#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route

Gateway of last resort is not set

1.0.0.0/24 is subnetted, 1 subnets
S       1.1.1.0 [1/0] via 192.168.1.1
2.0.0.0/32 is subnetted, 1 subnets
O IA    2.2.2.2 [110/11] via 172.16.1.2, 00:01:12, Ethernet1/1
3.0.0.0/24 is subnetted, 1 subnets
S       3.3.3.0 [1/0] via 192.168.1.1
4.0.0.0/32 is subnetted, 1 subnets
O IA    4.4.4.4 [110/11] via 172.16.1.2, 00:01:12, Ethernet1/1
C    172.16.0.0/16 is directly connected, Ethernet1/1
C    192.168.1.0/24 is directly connected, Ethernet1/0


R3#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route

Gateway of last resort is not set

1.0.0.0/24 is subnetted, 1 subnets
O E2    1.1.1.0 [110/20] via 172.16.1.1, 00:01:19, Ethernet1/0
2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, Loopback0
3.0.0.0/24 is subnetted, 1 subnets
O E2    3.3.3.0 [110/20] via 172.16.1.1, 00:01:19, Ethernet1/0
4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback2
C    172.16.0.0/16 is directly connected, Ethernet1/0
O    192.168.1.0/24 [110/20] via 172.16.1.1, 00:01:19, Ethernet1/0

测试:


R1#ping 4.4.4.4

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/19/28 ms
R1#ping 2.2.2.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/15/28 ms



R3#ping 1.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/20/24 ms
R3#ping 3.3.3.3

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/16/24 ms



如有转载请写明出处http://hi.baidu.com/key1088。