案例配置拓扑
案例配置要求
1、 互联IP为XY.1.1.X/24,Loopback 0的IP为X.X.X.X,其中X为本设备ID,Y为对端设备ID;
2、 三台路由器使用OSPF进行IGP通信;
3、 在R2上配置NAT,使得当R1用F0/0接口访问R3上F0/1接口的23和80端口时,进行NAT;
4、 当R1访问R3上F0/1的23端口时,NAT转换为R2的Loopback 0接口;
5、 当R1访问R3上F0/1的80端口时,NAT转换为R2的F0/1接口;
案例配置思路
1、 在R1、R2和R3上配置IP:
R1(config)#interface fastEthernet 0/0
R1(config-if)#ip address 12.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#interface loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R2(config)#interface fastEthernet 0/0
R2(config-if)#ip address 12.1.1.2 255.255.255.0
R2(config)#interface fastEthernet 0/1
R2(config-if)#ip address 23.1.1.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#interface loopback 0
R2(config-if)#ip address 2.2.2.2 255.255.255.0
R3(config)#interface fastEthernet 0/1
R3(config-if)#ip address 23.1.1.3 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#interface loopback 0
R3(config-if)#ip address 3.3.3.3 255.255.255.0
2、 在三台路由器上配置OSPF,为组播提供IGP连通性
R1(config)#router ospf 100
R1(config-router)#router-id 91.1.1.1
R1(config-router)#network 1.1.1.0 0.0.0.255 area 0
R1(config-router)#network 12.1.1.0 0.0.0.255 area 0
R2(config)#router ospf 100
R2(config-router)#router-id 92.2.2.2
R2(config-router)#network 2.2.2.0 0.0.0.255 area 0
R2(config-router)#network 12.1.1.0 0.0.0.255 area 0
R2(config-router)#network 23.1.1.0 0.0.0.255 area 0
R3(config)#router ospf 100
R3(config-router)#router-id 93.3.3.3
R3(config-router)#network 3.3.3.0 0.0.0.255 area 0
R3(config-router)#network 23.1.1.0 0.0.0.255 area 0
3、 在R2上配置NAT:
access-list 100 permit tcp host 12.1.1.1 host 23.1.1..3 eq telnet
access-list 101 permit tcp host 12.1.1.1 host 23.1.1.3 eq www
interface FastEthernet0/0
ip nat inside /设置接口为NAT进接口/
interface FastEthernet0/1
ip nat outside /设置接口为NAT出接口/
interface Loopback0
ip nat outside
ip nat inside source list 100 interface Loopback0 overload
/将ACL 100匹配到的流量的源IP转换为Loopback 0的IP/
ip nat inside source list 101 interface FastEthernet0/1 overload
/将ACL 101匹配到的流量的源IP转换为FastEthernet1/0的IP/
案例检测结果
R1访问R3的23和80端口后,在R2上查看NAT转换表的条目:
案例总结及其它
1、 NAT中由ip nat inside source开始的语句,会将从outside口发出的数据的源IP地址修改;
2、 ip nat inside source只能将源IP地址改为非 nat inside口的IP;