拓扑图如下:
上述设备用途说明:
1、使用R1做dhcp server
2、使用R2和R3代替电脑做dhcp client
3、SW1用做傻瓜交换机。
dhcp server配置(R1配置):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
R1#disable
#############使用 disable 命令退出特权模式
R1>
R1>enable
#############使用 enable 命令进入特权模式
R1#show privilege
Current privilege level is 15
#############查看特权模式的级别
############# 进入配置模式
R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#exit
#############查看接口状态
R1#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES unset administratively down down
FastEthernet0/1 unassigned YES unset administratively down down
Serial1/0 unassigned YES unset administratively down down
Serial1/1 unassigned YES unset administratively down down
Serial1/2 unassigned YES unset administratively down down
Serial1/3 unassigned YES unset administratively down down
R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
#############进入接口进行配置
R1(config)#int fastEthernet 0/0
R1(config-if)#no shutdown
R1(config-if)#
*Aug 1 19:39:28.523: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Aug 1 19:39:29.523: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#ip address 123.1.1.1 255.255.255.0
R1(config-if)#
R1(config-if)#
#############在配置模式中查看接口状态需要加 do 前缀
R1(config-if)#do show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 123.1.1.1 YES manual up up
FastEthernet0/1 unassigned YES unset administratively down down
Serial1/0 unassigned YES unset administratively down down
Serial1/1 unassigned YES unset administratively down down
Serial1/2 unassigned YES unset administratively down down
Serial1/3 unassigned YES unset administratively down down
R1(config-if)#
#############也可使用 end 命令退出配置模式
R1(config-if)#end
R1#
R1#
*Aug 1 19:43:17.991: %SYS-5-CONFIG_I: Configured from console by console
R1#
R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
#############开启dhcp server 功能
R1(config)#service dhcp
R1(config)#ip dhcp pool R123
R1(dhcp-config)#network 123.1.1.0 255.255.255.0
#############将客户端的网关指向 dhcp server 接口的IP
R1(dhcp-config)#default-router 123.1.1.1
#############将客户端的DNS指向 dhcp server 接口的IP
R1(dhcp-config)#dns-server 123.1.1.1
#############设置租期为1天0时1分
R1(dhcp-config)#lease 1 0 1
#############配置域名为cisco.com
R1(dhcp-config)#domain-name cisco.com
R1(dhcp-config)#
|
dhcp client配置(R2和R3配置):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
R2#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
#############禁用ip routing路由转发表,将路由器模拟为pc
R2(config)#no ip routing
R2(config)#int fastEthernet 0/0
R2(config-if)#no shutdown
R2(config-if)#
*Aug 1 19:07:41.279: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Aug 1 19:07:42.279: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
#############开启dhcp动态获取
R2(config-if)#ip address dhcp
R2(config-if)#
*Aug 1 19:11:47.891: %DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet0/0 assigned DHCP address 123.1.1.2, mask 255.255.255.0, hostname R2
R2(config-if)#end
#############查看接口状态
R2#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 123.1.1.2 YES DHCP up up
FastEthernet0/1 unassigned YES unset administratively down down
Serial1/0 unassigned YES unset administratively down down
Serial1/1 unassigned YES unset administratively down down
Serial1/2 unassigned YES unset administratively down down
Serial1/3 unassigned YES unset administratively down down
R2#
#############查看单独接口状态
R2#show running-config interface fastEthernet 0/0
Building configuration...
Current configuration : 94 bytes
!
interface FastEthernet0/0
ip address dhcp
no ip route-cache
duplex auto
speed auto
end
|
本文转自 f_066 51CTO博客,原文链接:http://blog.51cto.com/ganmu/1952781,如需转载请自行联系原作者