预配置:
r7isp
hostname r7isp
!
interface Serial5/0
ip address 20.0.0.100 255.255.255.0
no shutdown
!
end
r1
hostname r1
!
interface FastEthernet0/0
ip address 10.0.0.254 255.255.255.0
no shutdown
!
interface FastEthernet1/0
ip address 10.1.1.254 255.255.255.0
no shutdown
!
interface Serial5/0
ip address 20.0.0.1 255.255.255.0
no shutdown
!
end
r2pc
hostname r2pc
!
interface FastEthernet0/0
ip address 10.0.0.1 255.255.255.0
no shutdown
!
no ip routing
!
ip default-gateway 10.0.0.254
!
end
r3server
hostname r3server
!
interface FastEthernet1/0
ip address 10.1.1.1 255.255.255.0
no shutdown
!
no ip routing
!
ip default-gateway 10.1.1.254
!
end
需求场景 内部网络访问外网时,源地址转换为外网接口地址 PAT
企业总部内网 PC、Server,需访问互联网进行补丁升级,网关路由器r1对外接口只有一个公网地址,在路由器上配置源地址转换,当10.0.0.0/24和10.1.1.0/24访问外部资源时,将其源地址转换为网关公网接口地址20.0.0.1。
r1 配置如下:
interface FastEthernet0/0
ip address 10.0.0.254 255.255.255.0
ip nat inside
!
interface FastEthernet1/0
ip address 10.1.1.254 255.255.255.0
ip nat inside
!
interface Serial5/0
ip address 20.0.0.1 255.255.255.0
ip nat outside
ip address 20.0.0.1 255.255.255.0
!
ip nat inside source list PAT interface Serial5/0 overload
!
ip access-list extended PAT
permit ip 10.0.0.0 0.0.0.255 any
permit ip 10.1.1.0 0.0.0.255 any
!
end
验证:在r2pc 和 r3server上ping r7isp的接口地址20.0.0.100
r1上通过 show ip nat translations 命令查看NAT转换表项