#------------------Router0配置
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)# interface fa0/0
Router(config-if)#ip addr 192.168.1.254 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Router(config-if)#exit
Router(config)#interface fa0/1
Router(config-if)#ip addr 100.1.1.1 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
Router(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Router(config-if)#exit
Router(config)#interface fa0/0
Router(config-if)#ip nat inside
Router(config-if)#exit
Router(config)#interface fa0/1
Router(config-if)#ip nat outside
Router(config-if)#exit
Router(config)#access-list 1 permit 192.168.1.0 0.0.0.255
Router(config)#ip nat inside source list 1 int fa0/1 overload
Router(config)#ip route 0.0.0.0 0.0.0.0 100.1.1.2
Router(config)#ip nat inside source static tcp 192.168.1.3 80 100.1.1.1 80
Router(config)##查看nat转换表
Router(config)#do show ip nat translations
Pro Inside global Inside local Outside local Outside global
icmp 100.1.1.1:37 192.168.1.1:37 200.1.1.1:37 200.1.1.1:37
icmp 100.1.1.1:38 192.168.1.1:38 200.1.1.1:38 200.1.1.1:38
icmp 100.1.1.1:39 192.168.1.1:39 200.1.1.1:39 200.1.1.1:39
icmp 100.1.1.1:40 192.168.1.1:40 200.1.1.1:40 200.1.1.1:40
tcp 100.1.1.1:80 192.168.1.3:80 --- ---
tcp 100.1.1.1:80 192.168.1.3:80 200.1.1.1:1030 200.1.1.1:1030
#------------------Router0配置#------------------Router1配置
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface fa0/1
Router(config-if)#ip addr 100.1.1.2 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Router(config-if)#exit
Router(config)#interface fa0/0
Router(config-if)#ip addr 150.1.1.1 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
Router(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Router(config-if)#do show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type1, N2 - OSPF NSSA external type2
E1 - OSPF external type1, E2 - OSPF external type2, 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 set100.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 100.1.1.0/24 is directly connected, FastEthernet0/1
L 100.1.1.2/32 is directly connected, FastEthernet0/1
150.1.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 150.1.1.0/24 is directly connected, FastEthernet0/0
L 150.1.1.1/32 is directly connected, FastEthernet0/0
Router(config-if)#ip route 200.1.1.0 255.255.255.0 150.1.1.2
Router(config)##------------------Router1配置#------------------Router2配置
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface fa0/0
Router(config-if)#ip addr 150.1.1.2 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Router(config-if)#exit
Router(config)#interface fa0/1
Router(config-if)#ip addr 200.1.1.1 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Router(config-if)#no ip addr 200.1.1.1 255.255.255.0
Router(config-if)#ip addr 200.1.1.254 255.255.255.0
Router(config-if)#do show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type1, N2 - OSPF NSSA external type2
E1 - OSPF external type1, E2 - OSPF external type2, 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 set150.1.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 150.1.1.0/24 is directly connected, FastEthernet0/0
L 150.1.1.2/32 is directly connected, FastEthernet0/0
200.1.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 200.1.1.0/24 is directly connected, FastEthernet0/1
L 200.1.1.254/32 is directly connected, FastEthernet0/1
Router(config-if)#exit
Router(config)#ip route 100.1.1.0 255.255.255.0 150.1.1.1
Router(config)#no ip route 100.1.1.0 255.255.255.0 150.1.1.1
Router(config)#do show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type1, N2 - OSPF NSSA external type2
E1 - OSPF external type1, E2 - OSPF external type2, 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 set150.1.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 150.1.1.0/24 is directly connected, FastEthernet0/0
L 150.1.1.2/32 is directly connected, FastEthernet0/0
200.1.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 200.1.1.0/24 is directly connected, FastEthernet0/1
L 200.1.1.254/32 is directly connected, FastEthernet0/1
Router(config)#ip route 0.0.0.0 0.0.0.0 150.1.1.1
Router(config)##------------------Router2配置