Router>en Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int g0/0 Router(config-if)#ip addr 192.168.1.1255.255.255.0 Router(config-if)#no sh
Router(config-if)# %LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
配置接口g0/1
1 2 3 4 5 6 7 8 9
Router(config-if)#int g0/1 Router(config-if)# Router(config-if)#ip addr 200.8.7.1255.255.255.0 Router(config-if)#no sh
Router(config-if)# %LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up
Router(config-if)#do show run Building configuration...
Current configuration : 716 bytes ! version 15.1 no service timestamps log datetime msec no service timestamps debug datetime msec no service password-encryption ! hostname Router ! ! ! ! ! ! ! ! ip cef no ipv6 cef ! ! ! ! license udi pid CISCO1941/K9 sn FTX15248DH1- ! ! ! ! ! ! ! ! ! ! ! spanning-tree mode pvst ! ! ! ! ! ! interface GigabitEthernet0/0 ip address 192.168.1.1255.255.255.0 ip nat inside duplex auto speed auto ! interface GigabitEthernet0/1 ip address 200.8.7.1255.255.255.0 ip nat outside duplex auto speed auto ! interface Vlan1 no ip address shutdown ! ip nat inside source static192.168.1.5200.8.7.3 ip classless ! ip flow-export version 9 ! ! ! ! ! ! ! ! line con 0 ! line aux 0 ! line vty 04 login ! ! ! end
Ping statistics for200.8.7.100: Packets: Sent = 4, Received = 3, Lost = 1 (25% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms
C:\>
再回到Router,输入show ip nat translations
1 2 3 4 5 6 7 8
Router#show ip nat translations Pro Inside global Inside local Outside local Outside global icmp 200.8.7.3:5192.168.1.5:5200.8.7.100:5200.8.7.100:5 icmp 200.8.7.3:6192.168.1.5:6200.8.7.100:6200.8.7.100:6 icmp 200.8.7.3:7192.168.1.5:7200.8.7.100:7200.8.7.100:7 --- 200.8.7.3192.168.1.5 --- ---
Router#
动态NAT
使用 access-list 配置动态NAT,相关功能与配置信息如下
定义默认路由内部本地地址范围
这里的10我猜测是可通过10个不同的192.168.1.0/24地址访问?
1 2 3 4 5 6 7 8 9 10 11 12 13
Router(config)#access-list ? <1-99> IP standard access list <100-199> IP extended access list Router(config)#access-list 10 ? deny Specify packets to reject permit Specify packets to forward remark Access list entry comment Router(config)#access-list 10 permit ? A.B.C.D Address to match any Any source host host A single host address Router(config)#access-list 10 permit 192.168.1.00.0.0.255 Router(config)#
Router(config)#ip nat ? inside Inside address translation outside Outside address translation pool Define pool of addresses Router(config)#ip nat pool ? WORD Pool name Router(config)#ip nat pool abc ? A.B.C.D Start IP address Router(config)#ip nat pool abc 200.8.7.10 ? A.B.C.D End IP address Router(config)#ip nat pool abc 200.8.7.10200.8.7.20 ? netmask Specify the network mask Router(config)#ip nat pool abc 200.8.7.10200.8.7.20 netmask ? A.B.C.D Network mask Router(config)#ip nat pool abc 200.8.7.10200.8.7.20 netmask 255.255.255.0
建立映射关系
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Router(config)#ip nat ? inside Inside address translation outside Outside address translation pool Define pool of addresses Router(config)#ip nat inside ? source Source address translation Router(config)#ip nat inside source ? list Specify access list describing local addresses static Specify static local->global mapping Router(config)#ip nat inside source list ? <1-199> Access list number for local addresses WORD Access list name for local addresses Router(config)#ip nat inside source list 10 ? interface Specify interface forglobal address pool Name pool ofglobal addresses Router(config)#ip nat inside source list 10 pool ? WORD Name pool ofglobal addresses Router(config)#ip nat inside source list 10 pool
检查地址转换表
使用PC1 ping PC2,检查
地址转换表
1 2 3 4 5 6 7 8 9 10 11 12
Router(config)#show ip nat translations ^ % Invalid input detected at '^' marker. Router(config)#do show ip nat translations Pro Inside global Inside local Outside local Outside global icmp 200.8.7.10:10192.168.1.5:10200.8.7.100:10200.8.7.100:10 icmp 200.8.7.10:11192.168.1.5:11200.8.7.100:11200.8.7.100:11 icmp 200.8.7.10:12192.168.1.5:12200.8.7.100:12200.8.7.100:12 icmp 200.8.7.10:13192.168.1.5:13200.8.7.100:13200.8.7.100:13