昨天和哥们一块喝酒,说到他们单位从电信那里租用了4个公网地址,单位上想让领导单独使用一个IP地址,普通员工共同使用一个IP地址,服务器使用一个IP,在局域网中,领导、普通员工、服务器都是用私有地址并在一个网段内。
要实现这样的目标,主要是在企业出口路由器上应用PAT(端口地址转换)和NAT(网络地址转换)。下面是根据上面案例抽象出的网络模型:
拓扑图:
网络目标:
企业从ISP获得3个公网地址:200.1.1.1,168.1.1.2,168.1.1.3
C1,C2通过PAT使用200.1.1.1这个地址。
C3使用168.1.1.2;
C4使用168.1.1.3;
R1设置:
!
interface FastEthernet0/0
ip address 192.168.1.254 255.255.255.0
ip nat inside
ip virtual-reassembly
duplex auto
speed auto
interface Serial1/0
ip address 200.1.1.1 255.255.255.252
ip nat outside
serial restart-delay 0
ip route 0.0.0.0 0.0.0.0 200.1.1.2
ip nat inside source list 10 interface Serial1/0 overload
ip nat inside source static 192.168.1.3 168.1.1.2
ip nat inside source static 192.168.1.4 168.1.1.3
access-list 10 permit 192.168.1.1
access-list 10 permit 192.168.1.2
作为企业网关只需要设置上面的内容就可以实现我们的PAT和NAT设计目标了。可能会有朋友想知道R2的设置,列如下参考:
interface Serial0/0
ip address 200.1.1.2 255.255.255.252
interface Serial0/1
ip address 200.2.1.1 255.255.255.252
router eigrp 100
redistribute static metric 2048 20 255 255 1 (路由重分发)
passive-interface Serial0/0
network 200.1.1.0
network 200.2.1.0
no auto-summary
ip route 168.1.1.2 255.255.255.255 200.1.1.1
ip route 168.1.1.3 255.255.255.255 200.1.1.1
现面来验证试验结果(用wireshark监听R2的S0/0接口):
<a target="_blank" href="http://blog.51cto.com/attachment/201005/104237832.jpg"></a>
<a target="_blank" href="http://blog.51cto.com/attachment/201005/104422768.jpg"></a>
<a target="_blank" href="http://blog.51cto.com/attachment/201005/104457668.jpg"></a>
<a target="_blank" href="http://blog.51cto.com/attachment/201005/104555266.jpg"></a>
<a target="_blank" href="http://blog.51cto.com/attachment/201005/104643130.jpg"></a>
<a target="_blank" href="http://blog.51cto.com/attachment/201005/104725877.jpg"></a>
<a target="_blank" href="http://blog.51cto.com/attachment/201005/104802721.jpg"></a>
<a target="_blank" href="http://blog.51cto.com/attachment/201005/104834370.jpg"></a>
根据实验结果,PAT&NAT方案是成功的。
本文转自 tiger506 51CTO博客,原文链接:http://blog.51cto.com/tiger506/323326,如需转载请自行联系原作者