端口NAT小案例及延伸




R1:

conf ter

int f1/0

ip add 192.168.1.1  255.255.255.0

no shu

no ip routing

Ip  default-ga 192.168.1.2

exit

R2:

conf ter

int f1/0

ip add 192.168.1.2 255.255.255.0

no shu

int f1/1

ip add 23.1.1.1  255.255.255.0

no shu

ip route 0.0.0.0 0.0.0.0 f1/1 //边界设置默认路由

int f1/0

ip nat inside //指定内接口

exit

int f1/1

ipnat outside //

exit

access-list 1 permit 192.168.1.0   0.0.0.255  //摘出内网地址段

ip nat inside source list 1 int f1/1 overload    //指定端口,实现依赖端口转发数据

R3:

conf ter

int f1/0

ip add 23.1.1.2  255.255.255.0

no shu

int loo 0

ip add 3.3.3.3   255.255.255.0

no shu

exit

测试:

R1#ping 3.3.3.3

Type escape sequenceto abort.

Sending 5, 100-byteICMP Echos to 3.3.3.3, timeout is 2 seconds:

!!!!!

Success rate is 100percent (5/5), round-trip min/avg/max = 264/328/380 ms

拓展: 在案例基础上,实现外网也可以访问内网(用telnet来模拟即可)

R2(config):ip nat inside source static tcp 192.168.1.1 23 3.3.3.3 23

R3(config): line vtp 0 4 //password cisco //login  //配置telnet的命令

R3:telnet 23.1.1.1     可发现直接登录到R1上。

你可能感兴趣的:(端口NAT小案例及延伸)