如上图所示:
我们需要将局域网里的两台电脑( PC0 和 PC1 )
能通过路由器来访问模拟外网的 PC2
这时候我们就需要在路由器上配置静态 NAT 转发
配置方法如下:
先按照上图拓扑图配置好ip地址
将路由器的接口启动配置好ip
然后进入路由器,进入接口分别指定哪个接口是内网接口、哪个接口是外网接口。
配置方法是进入内网接口输入(ip nat inside)指定为nat 的内网接口
外网是进入外网接口输入(ip nat outside)指定为nat 的外网接口
Router>en
Router#conf
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#in f0/1
Router(config-if)#no sh
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Router(config-if)#ip add 192.168.1.254 255.255.255.0
Router(config-if)#ip nat inside
Router(config-if)#e
Router(config)#in f0/0
Router(config-if)#no sh
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Router(config-if)#ip add 61.196.77.10 255.255.255.0
Router(config-if)#ip nat outside
Router(config-if)#e
Router(config)#ip nat inside source static 192.168.1.1 61.196.77.10
Router(config)#ip nat inside source static 192.168.1.2 61.196.77.10
Router(config)#end
Router#
%SYS-5-CONFIG_I: Configured from console by console
w
Building configuration...
[OK]
Router#
Router#