一:实验拓扑:

 

Cisco DHCP and NAT config_Cisco

 

2:实验配置:

int f0/0

ip add 192.168.0.1 255.255.255.0

no sh

ip nat inside

int s2/2

ip add 1.1.1.1 255.255.255.0

ip nat outside

access-list 1 permit 192.168.0.0 255.255.255.0

ip nat inside source list 1 interface s2/2 overload

===================================================

ip dhcp pool VLAN1

network 192.168.0.0 255.255.255.0

default-router 192.168.0.1

dns-server 61.134.1.4

domain-name my3377.com

lease infinite

ip dhcp excluded-address 192.168.0.1

R1#

interface FastEthernet0/0

ip address dhcp

R3#   

interface Serial2/1

ip address 1.1.1.2 255.255.255.0

R1#show ip int b

Interface                  IP-Address      OK? Method Status                Protocol

FastEthernet0/0            192.168.0.2     YES DHCP   up                    up     

Serial2/0                  unassigned      YES unset administratively down down   

R1#ping 1.1.1.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 1.1.1.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 8/43/124 ms

R3#debug ip packet

IP packet debugging is on

R3#

*Oct 7 17:05:10.959: IP: tableid=0, s=1.1.1.1 (Serial2/1), d=1.1.1.2 (Serial2/1), routed via RIB

*Oct 7 17:05:10.963: IP: s=1.1.1.1 (Serial2/1), d=1.1.1.2 (Serial2/1), len 100, rcvd 3

*Oct 7 17:05:10.963: IP: tableid=0, s=1.1.1.2 (local), d=1.1.1.1 (Serial2/1), routed via FIB

*Oct 7 17:05:10.967: IP: s=1.1.1.2 (local), d=1.1.1.1 (Serial2/1), len 100, sending

*Oct 7 17:05:11.015: IP: tableid=0, s=1.1.1.1 (Serial2/1), d=1.1.1.2 (Serial2/1), routed via RIB

*Oct 7 17:05:11.019: IP: s=1.1.1.1 (Serial2/1), d=1.1.1.2 (Serial2/1), len 100, rcvd 3

*Oct 7 17:05:11.019: IP: tableid=0, s=1.1.1.2 (local), d=1.1.1.1 (Serial2/1), routed via FIB

*Oct 7 17:05:11.023: IP: s=1.1.1.2 (local), d=1.1.1.1 (Serial2/1), len 100, sending

*Oct 7 17:05:11.059: IP: tableid=0, s=1.1.1.1 (Serial2/1), d=1.1.1.2 (Serial2/1), routed via RIB

*Oct 7 17:05:11.063: IP: s=1.1.1.1 (Serial2/1), d=1.1.1.2 (Serial2/1), len 100, rcvd 3

*Oct 7 17:05:11.063: IP: tableid=0, s=1.1.1.2 (local), d=1.1.1.1 (Seri

R3#al2/1), routed via FIB

*Oct 7 17:05:11.063: IP: s=1.1.1.2 (local), d=1.1.1.1 (Serial2/1), len 100, sending

*Oct 7 17:05:11.071: IP: tableid=0, s=1.1.1.1 (Serial2/1), d=1.1.1.2 (Serial2/1), routed via RIB

*Oct 7 17:05:11.075: IP: s=1.1.1.1 (Serial2/1), d=1.1.1.2 (Serial2/1), len 100, rcvd 3

*Oct 7 17:05:11.075: IP: tableid=0, s=1.1.1.2 (local), d=1.1.1.1 (Serial2/1), routed via FIB

*Oct 7 17:05:11.075: IP: s=1.1.1.2 (local), d=1.1.1.1 (Serial2/1), len 100, sending

*Oct 7 17:05:11.083: IP: tableid=0, s=1.1.1.1 (Serial2/1), d=1.1.1.2 (Serial2/1), routed via RIB

*Oct 7 17:05:11.087: IP: s=1.1.1.1 (Serial2/1), d=1.1.1.2 (Serial2/1), len 100, rcvd 3

*Oct 7 17:05:11.087: IP: tableid=0, s=1.1.1.2 (local), d=1.1.1.1 (Serial2/1), routed via FIB

*Oct 7 17:05:11.087: IP: s=1.1.1.2 (local), d=1.1.1.1 (Serial2/1), len 100, sending

R2#show ip nat translations

Pro Inside global      Inside local       Outside local      Outside global

icmp 1.1.1.1:9         192.168.0.2:9      1.1.1.2:9          1.1.1.2:9