很久之前交给老师的作业,今天不小心翻到,存到blog中,这样安全。
实验环境:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
使用下面拓扑图作网络环境的模拟,10.1.1.0和172.16.1.0子网分别作为内部子网,通过地址翻译访问外部网络。
一、静态NAT的配置
A(config)#int f0/0
A(config-if)#ip addr 10.1.1.1 255.255.255.0
A(config-if)#no shut
A(config)#int f0/1
A(config-if)#ip addr 192.168.1.1 255.255.255.0
A(config-if)#no shut
A(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.2
A(config)#ip nat inside source static 10.1.1.2 192.168.1.10
A(config)#ip nat inside source static 10.1.1.3 192.168.1.11
A(config)#int f0/0
A(config-if)#ip nat inside
A(config)#int f0/1
A(config-if)#ip nat outside
B(config)#int f0/0
B(config-if)#ip addr 172.16.1.1 255.255.255.0
B(config-if)#no shut
B(config)#int f0/1
B(config-if)#ip addr 192.168.1.2 255.255.255.0
B(config-if)#no shut
B(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.1
B(config)#ip nat inside source static 172.16.1.2 192.168.1.20
B(config)#ip nat inside source static 172.16.1.3 192.168.1.21
B(config)#int f0/0
B(config-if)#ip nat inside
B(config)#int f0/1
B(config-if)#ip nat outside
二、动态NAT的配置
A(config)#int f0/0
A(config-if)#ip addr 10.1.1.1 255.255.255.0
A(config-if)#no shut
A(config)#int f0/1
A(config-if)#ip addr 192.168.1.1 255.255.255.0
A(config-if)#no shut
A(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.2
A(config)#ip nat pool benet 192.168.1.100 192.168.1.150 netmask 255.255.255.0
A(config)#access-list 1 permit 10.1.1.0 0.0.0.255 //
接口不应用此条无效
A(config)#ip nat inside source list 1 pool benet //
将访问控制列表1中的局部地址转换为benet地址池中定义的全局IP地址,如有多个地址池可一一添加
A(config)#int f0/0
A(config-if)#ip nat inside
A(config)#int f0/1
A(config-if)#ip nat outside
B(config)#int f0/0
B(config-if)#ip addr 172.16.1.1 255.255.255.0
B(config-if)#no shut
B(config)#int f0/1
B(config-if)#ip addr 192.168.1.2 255.255.255.0
B(config-if)#no shut
B(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.1
B(config)#ip nat pool benet11 192.168.1.151 192.168.1.200 prefix-length 24 type rotary //
掩码长度写法等价于前,地址池中的地址为循环使用
B(config)#access-list 1 permit 172.16.1.0 0.0.0.255
B(config)#ip nat inside source list 1 pool benet11
B(config)#int f0/0
B(config-if)#ip nat inside
B(config)#int f0/1
B(config-if)#ip nat outside
三、PAT的配置
A(config)#int f0/0
A(config-if)#ip addr 10.1.1.1 255.255.255.0
A(config-if)#no shut
A(config)#int f0/1
A(config-if)#ip addr 192.168.1.1 255.255.255.0
A(config-if)#no shut
A(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.2
A(config)#ip nat pool onlyone 192.168.1.20 192.168.1.20 netmask 255.255.255.0 //
定义合法IP地址池,地址池名字onlyone,由于只有一个地址,所以起始地址与终止地址相同
A(config)#access-list 1 permit 10.1.1.0 0.0.0.255
A(config)#ip nat inside source list 1 pool onlyone overload //
以端口复用方式,将访问控制列表1中的局部地址转换为onlyone地址池中定义的全局IP地址
A(config)#int f0/0
A(config-if)#ip nat inside
A(config)#int f0/1
A(config-if)#ip nat outside
B(config)#int f0/0
B(config-if)#ip addr 172.16.1.1 255.255.255.0
B(config-if)#no shut
B(config)#int f0/1
B(config-if)#ip addr 192.168.1.2 255.255.255.0
B(config-if)#no shut
B(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.1
B(config)#access-list 1 permit 172.16.1.0 0.0.0.255
B(config)#ip nat inside source list 1 interface f0/1 overload //
以端口复用方式,将访问控制列表1中的私有地址转换为路由器外部接口的合法IP地址,由于直接使用外部接口地址,所以不再定义IP地址池
B(config)#int f0/0
B(config-if)#ip nat inside
B(config)#int f0/1
B(config-if)#ip nat outside
验证:
<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />
Ping
Show ip nat translation
Show ip nat statistics
Debug ip nat
Clear ip nat translation * //
清除所有转换
转载于:https://blog.51cto.com/cnxfei/130716