本實驗使用PT來完成DHCP,NAT,DNS的一個實驗集合,個人感覺很好玩的一個實驗,雖然實驗很簡單,但是能夠明確的表達出DHCP運行的過程,以及DNS運作同時還有NAT的轉換。好了,開始:
實驗拓撲
配置要點
PC0使用動態獲取地址:
路由器DHCP的相關配置:
ip dhcp excluded-address 192.168.1.1 192.168.1.10
ip dhcp pool A
network 192.168.1.0 255.255.255.0
default-router 192.168.1.1
dns-server 172.16.10.2
看下兩個路由器的路由表:
R1#show ip route
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial0/3/0
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.10.0 is directly connected, FastEthernet0/1
C 192.168.1.0/24 is directly connected, FastEthernet0/0
S* 0.0.0.0/0 [1/0] via 12.1.1.2
R2#show ip route
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial0/3/0
C 202.102.224.0/24 is directly connected, FastEthernet0/0
R1上做了NAT:
ip nat pool A 12.1.1.1 12.1.1.1 netmask 255.255.255.0
ip nat inside source list 1 pool A overload
ip classless
ip route 0.0.0.0 0.0.0.0 12.1.1.2
access-list 1 permit 192.168.1.0 0.0.0.255
所以PC0可以和Server1通信:
PC>ping 202.102.224.68
Pinging 202.102.224.68 with 32 bytes of data:
Reply from 202.102.224.68: bytes=32 time=94ms TTL=126
Reply from 202.102.224.68: bytes=32 time=93ms TTL=126
Reply from 202.102.224.68: bytes=32 time=94ms TTL=126
Reply from 202.102.224.68: bytes=32 time=94ms TTL=126
Ping statistics for 202.102.224.68:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 93ms, Maximum = 94ms, Average = 93ms
查看R1的dubug信息:
R1#debug ip nat
IP NAT debugging is on
NAT: s=192.168.1.11->12.1.1.1, d=202.102.224.68 [17]
NAT*: s=202.102.224.68, d=12.1.1.1->192.168.1.11 [27]
最後看下Server0設置:
前邊截圖可以看到,PC0的DNS指向Server0,最後訪問一下www.google.com:
看下Server1上的設置:
很好玩吧!