一、拓扑图
1、拓扑图
2、原理
①、内网的IP地址,到了Router1的外网端口后,经过NAT的IP地址转换,将IP包头中的源IP地址(私有),转换为自己的公网IP地址。
②、在IP进行转换后,路由器随机产生端口号,替换源帧中,TCP/UDP包头中,源PC主机上的端口号,即:
在NAT地址转换表中产生如下记录:
3、要求
实现多台内网PC同时访问外网(动态PAT),由外网访问内网服务器(静态PAT)
二、路由设置
1、开启端口,配置路由表
①、开启端口,配置IP
Router1:configure terminal
interface f0/0
ip address 192.168.1.254 255.255.255.0
no shutdown
exit
interface f0/1
ip address 100.0.0.1 255.255.255.0
no shutdown
exit
Router2:configure terminal
interface f0/0
ip address 100.0.0.111 255.255.255.0
no shutdown
exit
interface f0/1
ip address 200.0.0.1 255.255.255.0
no shutdown
exit
Router3:configure terminal
interface f0/0
ip address 200.0.0.2 255.255.255.0
no shutdown
exit
interface f0/1
ip address 203.0.0.254 255.255.255.0
no shutdown
exit
②、配置路由表
Router1:configure terminal
ip route 0.0.0.0 0.0.0.0 100.0.0.111
Router2:configure terminal
ip route 203.0.0.0 255.255.255.0 200.0.0.2
exit
Router3:configure terminal
ip route 100.0.0.0 255.255.255.0 200.0.0.1
exit
2、动态PAT设置
①、设置内外网端口
Router1:configure terminal
interface f0/0
ip nat inside
exit
interface f0/1
ip nat outside
exit
②、定义内部地址池
Router1:configure terminal
access-list 1 permit 192.168.0.0 0.0.255.255
exit
③、做PAT动态映射
Router1:configure terminal
ip nat inside source list 1 int f0/1 overload
exit
3、静态PAT设置
①、静态PAT端口转换
Router1:configure terminal
ip nat inside source static tcp 192.168.1.3 80 100.0.0.2 80
ip nat inside source static tcp 192.168.1.4 21 100.0.0.2 21