1.定義訪問控制列表:網絡
router(config)#access-list 1 permit 10.1.1.0 0.0.0.255
2.定義合法IP地址池:ide
router(config)#ip nat pool onlyone 61.159.62.131 61.159.62.131 netmask 255.255.255.248
3.實現網絡地址轉換:測試
router(config)#ip nat insde source list 1 pool onlyone overload
4.在內部和外部端口上啓用NAT,以及配置默認路由:與靜態NAT配相同
5.定義內部訪問列表:debug
router(config)#access-list 1 permit 10.1.1.0 0.0.0.255
6.定義合法的IP地址池:
因爲直接使用外部接口地址,因此不在定義IP地址池
7.設置複用動態IP地址轉換命令示例:調試
router(config)#ip nat inside source list 1 interface FastEthernet 0/0 overload
一、主機配置地址code
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
二、配置交換機router
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
三、路由上配置PAT列表blog
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 #特權模式下打開NAT調試功能,ping時查看具體調試過程 IP NAT debugging is on
四、測試列表配置是否正確接口
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這個外網地址
總結:
一、PAT是企業中使用最多的列表配置方式,大大節省了可用公網IP地址的資源枯竭。ip