R1:
no ip routing(不做路由協議了,可以把R1看成是一臺電腦)
interface Serial0
ip address 192.168.10.1 255.255.255.0
ip default-gateway 192.168.10.5
R2:
interface Serial0
ip address 192.168.10.5 255.255.255.0
ip nat inside(定義內部端口)
clockrate 64000
interface Serial1
ip address 23.1.1 .2 255.255.255.0
ip nat outside(定義外部端口)
clockrate 64000
ip nat pool ABC 23.1.1 .2 23.1.1.2 netmask 255.255.255.0(告訴路由器外網地址範圍)
access-list 1 permit 192.168.10.0 0.0.0 .255(告訴路由器內網地址範圍)
ip nat inside source list 1 pool ABC overload(將內網地址和外網地址做轉換)(注意:“overload”,其轉換方式是複用動態地址轉換)
ip route 0.0.0 .0 0.0.0.0 23.1.1.3(做默認路由指向外網)
R3:
interface Loopback1
ip address 2.2.2 .2 255.0.0.0
interface Serial1
ip address 23.1.1 .3 255.255.255.0
R1#ping 2.2.2 .2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2 .2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 64/65/72 ms
R2#sh ip nat trans
Pro Inside global Inside local Outside local Outside global
icmp 23.1.1 .2:3896 192.168.10.1:3896 2.2.2.2:3896 2.2.2 .2:3896
icmp 23.1.1 .2:3897 192.168.10.1:3897 2.2.2.2:3897 2.2.2 .2:3897
icmp 23.1.1 .2:3898 192.168.10.1:3898 2.2.2.2:3898 2.2.2 .2:3898
icmp 23.1.1 .2:3899 192.168.10.1:3899 2.2.2.2:3899 2.2.2 .2:3899
icmp 23.1.1 .2:3900 192.168.10.1:3900 2.2.2.2:3900 2.2.2 .2:3900