NAT网络地址转换实验

NAT配置步骤
1、接口IP地址配置
2、使用访问控制列表定义哪些内部主机能做nat
3、决定采用什么公有地址,(静态或地址池)
4、指定地址转换映射
5在内部和外部端口上启用nat
只做个静态的,需要动态的可以访问个人站点索求

优化命令(所有路由与交换机):
R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#no ip domain lookup
R1(config)#line console 0
R1(config-line)#logging syn
R1(config-line)#exec-time 0 0
R1(config-line)#end


Pc的ip 与掩码255.255.255.0 以及网关自己配
R0:s0/0[200.200.200.1]
R1:s0/0[200.200.200.2]

R0#
R0#conf t
R0(config)#interface f0/0
R0(config-if)#ip add 192.168.1.1 255.255.255.0
R0(config-if)#no shutdown 

R0(config-if)#inter s0/0
R0(config-if)#ip add 200.200.200.1 255.255.255.0
R0(config-if)#no shutdown 
R0(config-if)#end
R0#

R0#
R0#conf t
R0(config)#interface Serial0/0
R0(config-if)#clock rate 4800
R0(config-if)#end
R0#


R1#
R1#conf t
R1(config)#
R1(config)#int s0/0
R1(config-if)#ip add 200.200.200.2 255.255.255.0
R1(config-if)#no sh
R1(config-if)#end
R1#

R1#
R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#ip route 0.0.0.0 0.0.0.0 s0/0
R1(config)#end
R1#


静态NAT
在R0上配置
R0#
R0#conf t
R0(config)#ip nat inside so
R0(config)#ip nat inside source sta
R0(config)#ip nat inside source static 192.168.1.2 200.200.200.10
R0(config)#ip nat inside source static 192.168.1.3 200.200.200.20
R0(config)#end
R0#

//查看结果
R0#show ip nat tr
R0#show ip nat translations 
Pro  Inside global     Inside local       Outside local      Outside global
---  200.200.200.10    192.168.1.2        ---                ---
---  200.200.200.20    192.168.1.3        ---                ---

R0#
R0#conf t
R0(config)#interface f0/0
R0(config-if)#ip nat inside
R0(config-if)#
R0(config-if)#interface s0/0
R0(config-if)#ip nat outside
R0(config-if)#exit
R0(config)#end
R0#

R0#
R0#show ip int brief 
Interface              IP-Address      OK? Method Status                Protocol
FastEthernet0/0        192.168.1.1     YES manual up                    up
Serial0/0              200.200.200.1   YES manual up                    up
Serial0/1              unassigned      YES unset  administratively down down
R0#R0上打开debug检测
R0#
R0#deb
R0#debug ip nat
IP NAT debugging is on
R0#


PC>ping 200.200.200.2
R0#
NAT: s=192.168.1.3->200.200.200.20, d=200.200.200.2 [9]
NAT*: s=200.200.200.2, d=200.200.200.20->192.168.1.3 [19]
R0#
NAT: s=192.168.1.3->200.200.200.20, d=200.200.200.2 [10]
NAT*: s=200.200.200.2, d=200.200.200.20->192.168.1.3 [20]

R0#
NAT: s=192.168.1.3->200.200.200.20, d=200.200.200.2 [11]
NAT*: s=200.200.200.2, d=200.200.200.20->192.168.1.3 [21]
R0#
NAT: s=192.168.1.3->200.200.200.20, d=200.200.200.2 [12]
NAT*: s=200.200.200.2, d=200.200.200.20->192.168.1.3 [22]
R0#
NAT: expiring 200.200.200.20 (192.168.1.3) icmp 5 (5)
R0#
NAT: expiring 200.200.200.20 (192.168.1.3) icmp 6 (6)
R0#
NAT: expiring 200.200.200.20 (192.168.1.3) icmp 7 (7)
R0#
NAT: expiring 200.200.200.20 (192.168.1.3) icmp 8 (8)
R0#R1上打开debug检测
R1#
R1#debug ip packet 
Packet debugging is on
R1#
--------- ----- --- ---------------------------------------------------------------------------------------------------
静态nat无法用clear清除//下面为检验
----------------------------------------------------------------------------------------------------------------------
R0#
R0#clear ip nat t
R0#clear ip nat translation *
R0#
R0#show ip nat tr
R0#show ip nat translations 
Pro  Inside global     Inside local       Outside local      Outside global
---  200.200.200.10    192.168.1.2        ---                ---
---  200.200.200.20    192.168.1.3        ---                ---
--------- ----- --- ---------------------------------------------------------------------------------------------------
静态nat无法用clear清只能手动删除----------------------------------------------------------------------------------------------------------------------
R0#
R0#conf t
R0(config)#no ip nat inside source static 192.168.1.2 200.200.200.10
R0(config)#no ip nat inside source static 192.168.1.3 200.200.200.20
R0(config)#R0#show ip nat translations就没有啦!!!咱就不删内部接口,与外部接口啦


你可能感兴趣的:(网络分类)