router(config)#access-list 1 permit 10.1.1.0 0.0.0.255
router(config)#ip nat pool onlyone 61.159.62.131 61.159.62.131 netmask 255.255.255.248
router(config)#ip nat insde source list 1 pool onlyone overload
router(config)#access-list 1 permit 10.1.1.0 0.0.0.255
因爲直接使用外部接口地址,因此不在定義IP地址池shell
router(config)#ip nat inside source list 1 interface FastEthernet 0/0 overload
sw#conf t sw(config)#no ip routing sw(config)#int f1/0 sw(config-if)#speed 100 sw(config-if)#dup full sw(config-if)#ex
R1#conf t R1(config)#int f0/0 R1(config-if)#ip add 192.168.100.1 255.255.255.0 R1(config-if)#no shut R1(config-if)#int f0/1 R1(config-if)#ip add 12.0.0.1 255.255.255.0 R1(config-if)#no shut R1(config-if)#ex R1(config)#access-list 1 permit 192.168.100.0 0.0.0.255 R1(config)#ip nat inside source list 1 interface fastEthernet 0/1 overload R1(config)#int f0/0 R1(config-if)#ip nat inside R1(config-if)#int f0/1 R1(config-if)#ip nat outside R1(config-if)#end R1#debug ip nat IP NAT debugging is on
PC1> ip 192.168.100.10 192.168.100.1 Checking for duplicate address... PC1 : 192.168.100.10 255.255.255.0 gateway 192.168.100.1 PC2> ip 192.168.100.20 192.168.100.1 Checking for duplicate address... PC1 : 192.168.100.20 255.255.255.0 gateway 192.168.100.1 PC3> ip 12.0.0.12 12.0.0.1 Checking for duplicate address... PC1 : 12.0.0.12 255.255.255.0 gateway 12.0.0.1
PC1> ping 12.0.0.12 -t 12.0.0.12 icmp_seq=1 timeout 84 bytes from 12.0.0.12 icmp_seq=2 ttl=63 time=31.424 ms 84 bytes from 12.0.0.12 icmp_seq=3 ttl=63 time=31.560 ms 84 bytes from 12.0.0.12 icmp_seq=4 ttl=63 time=31.278 ms 84 bytes from 12.0.0.12 icmp_seq=5 ttl=63 time=39.174 ms R1# *Mar 1 00:12:39.347: NAT: s=192.168.100.10->12.0.0.1, d=12.0.0.12 [48340] //此時在R1中能夠看到192.168.100.10轉換成12.0.0.1這個外網地址 PC2> ping 12.0.0.12 -t 84 bytes from 12.0.0.12 icmp_seq=1 ttl=63 time=31.402 ms 84 bytes from 12.0.0.12 icmp_seq=2 ttl=63 time=33.339 ms 84 bytes from 12.0.0.12 icmp_seq=3 ttl=63 time=38.074 ms R1# *Mar 1 00:15:17.887: NAT*: s=192.168.100.20->12.0.0.1, d=12.0.0.12 [48502] //此時在R1中能夠看到192.168.100.20也轉換成12.0.0.1這個外網地址