NAT動態配置
將內部地址192.168.100.2~192.168.100.54轉換爲合法地址61.159.62.131~61.159.62.190,以便訪問Internet
定義訪問控制列表:
router(confi)#access-list 1 permit 192.168.100.0 0.0.0.255
定義合法IP地址池:
router(config)#ip nat pool test0 61.159.62.131 61.159.62.190 netmask 255.255.255.192
實現網絡地址轉換:
router(config)#ip nat inside source list 1 pool test0
在內部和外部端口上啓用NAT,以及配置默認路由:與靜態NAT配置相同
Demo3:動態NAT
sw:
sw#conf t
sw(config)#no ip routing
sw(config)#int f1/0
sw(config-if)#speed 100
sw(config-if)#dup full
R1:
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
NAT動態地址轉換配置:
R1:
R1(config)#access-list 1 permit 192.168.100.0 0.0.0.255
//內部轉化地址段落
R1(config)#ip nat pool test 12.0.0.10 12.0.0.100 netmask 255.255.255.0
//外部轉換地址段落
R1(config)#ip nat inside source list 1 pool test
//引用地址池
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
主機寫IP地址:
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=50.159 ms
84 bytes from 12.0.0.12 icmp_seq=3 ttl=63 time=31.241 ms
84 bytes from 12.0.0.12 icmp_seq=4 ttl=63 time=35.309 ms
84 bytes from 12.0.0.12 icmp_seq=5 ttl=63 time=37.707 ms
*Mar 1 00:16:43.395: NAT: s=192.168.100.10->12.0.0.10, d=12.0.0.12 [13566]
//地址轉換成功
PC2> ping 12.0.0.12 -t
84 bytes from 12.0.0.12 icmp_seq=1 ttl=63 time=19.590 ms
84 bytes from 12.0.0.12 icmp_seq=2 ttl=63 time=23.424 ms
84 bytes from 12.0.0.12 icmp_seq=3 ttl=63 time=27.049 ms
*Mar 1 00:19:10.567: NAT*: s=192.168.100.20->12.0.0.11, d=12.0.0.12 [13713]
//另一個地址也轉換成功
以上就是動態NAT的地址轉換,不須要手動進行指定,他自動轉換的都是區間範圍內的地址