PC1(config)#int f0/0
PC1(config-if)#ip add 192.168.1.10 255.255.255.0
PC1(config-if)#no sh
PC1(config-if)#exit
PC1(config)#ip default-gateway 192.168.1.254
PC1(config)#end
PC1#
---------------------------PC2------------------------------
Router(config-line)#host PC2
PC2(config)#no ip routing
PC2(config)#ip default-gateway 192.168.2.254
PC2(config)#int f0/0
PC2(config-if)#ip add 192.168.2.10 255.255.255.0
PC2(config-if)#no sh
--------------------------Sw1----------------------------------
Sw1(config)#int f0/2
Sw1(config-if)#switchport trunk encapsulation dot1q
Sw1(config-if)#switchport mode trunk
Sw1#vlan database
Sw1(vlan)#vlan 10 name caiwubo
VLAN 10 added:
Name: xiaoshoubo
Sw1(vlan)#vlan 20 name xiaoshoubo
VLAN 20 added:
Name: renshibo
Sw1(vlan)#exit
APPLY completed.
Exiting....
Sw1#conf t
Sw1(config-if)#switchport mode access
Sw1(config-if)#switchport access vlan 10
Sw1(config-if)#spanning-tree portfast
Sw1(config-if)#int f0/1
Sw1(config-if)#switchport mode access
Sw1(config-if)#switchport access vlan 20
Sw1(config-if)#spanning-tree portfast
Sw1(config-if)#end
---- -------------------------------- --------- ---
1 default active Fa0/2, Fa0/3, Fa0/4, Fa0/5
Fa0/6, Fa0/7, Fa0/8, Fa0/9
Fa0/10, Fa0/11, Fa0/12, Fa0/13
Fa0/14, Fa0/15
10 xiaoshoubo active Fa0/0
20 renshibo active Fa0/1
R2(config)#int e0/0
R2(config-if)#ip add 200.1.1.1 255.255.255.0
R2(config-if)#duplex full
R2(config-if)#no sh
R2(config-if)#ip nat outside
R2(config-if)#exit
R2(config)#int e0/2
R2(config-if)#duplex full
R2(config-if)#no sh
R2(config-if)#exit
R2(config)#int e0/2.10
R2(config-subif)#encapsulation dot1q 10
R2(config-subif)#ip add 192.168.1.254 255.255.255.0
R2(config-subif)#ip nat inside
R2(config-subif)#ip access-group 150 in
R2(config-subif)#exit
R2(config)#int e0/2.20
R2(config-subif)#encapsulation dot1q 20
R2(config-subif)#ip add 192.168.2.254 255.255.255.0
R2(config-subif)#ip nat inside
R2(config-subif)#exit
R2(config)#ip route 0.0.0.0 0.0.0.0 200.1.1.3
R2(config)#acc 100 permit ip 192.168.1.0 0.0.0.255 any
R2(config)#acc 100 permit ip 192.168.2.0 0.0.0.255 any
R2(config)#ip nat inside source list 100 int e0/0 overload
R2(config)#acc 150 deny tcp 192.168.1.0 0.0.0.255 host 192.168.1.254
R2(config)#acc 150 deny tcp 192.168.1.0 0.0.0.255 host 192.168.2.254
R2(config)#acc 150 deny tcp 192.168.1.0 0.0.0.255 host 200.1.1.1
R2(config)#acc 150 permit ip any any
R2(config-line)#password P@ssw0rd
R2(config-line)#login
R2(config-line)#exit
R2(config)#enable secret P@ssw0rd
------------------------------R3--------------------------------
R3#conf t
R3(config)#int e0/0
R3(config-if)#ip add 200.1.1.3 255.255.255.0
R3(config-if)#duplex full
R3(config-if)#no sh
R3(config-if)#exit
R3(config)#ip http server
R3(config)#line vty 0 4
R3(config-line)#no login
R3(config-line)#privilege level 15
R3(config-line)#exit
R3(config)#int lo0
R3(config-if)#ip add 222.222.222.222 255.255.255.0
R3(config-if)#exit
R3(config)#ip route 0.0.0.0 0.0.0.0 200.1.1.1
PC1#telnet 200.1.1.1
Trying 200.1.1.1 ...
% Destination unreachable; gateway or host down
Trying 192.168.2.254 ...
% Destination unreachable; gateway or host down
Trying 192.168.1.254 ...
% Destination unreachable; gateway or host down
Trying 192.168.1.254 ... Open
User Access Verification
PC2#telnet 192.168.2.254
Trying 192.168.2.254 ... Open
User Access Verification
PC2#telnet 200.1.1.1
Trying 200.1.1.1 ... Open
User Access Verification
PC2#
Trying 222.222.222.222 ... Open
Line User Host(s) Idle Location
0 con 0 idle 00:08:38
*130 vty 0 idle 00:00:00 200.1.1.1
当 192.168.2.10去telnet 222.222.222.222
被转换为200.1.1.1去telnet 222.222.222.222
R2#sh ip nat translations
Pro Inside global Inside local Outside local Outside global
tcp 200.1.1.1:11007 192.168.1.10:11007 222.222.222.222:23 222.222.222.222:23
tcp 200.1.1.1:11005 192.168.2.10:11005 222.222.222.222:23 222.222.222.222:23
R2#