DHCP配置
2018-11-15 本文已影响0人
不忘初心铃
TIM截图20181115170902-3.jpg
全局DHCP配置
在R1上面开启dhcp服务,并配置全局dhcp
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.100.1 24
[R1-GigabitEthernet0/0/0]qu
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip address 192.168.200.1 24
[R1-GigabitEthernet0/0/1]qu
[R1-ip-pool-pool_1]dns-list 192.168.100.2 #客户端自动获取的dns服务器ip
[R1-ip-pool-pool_1]gateway-list 192.168.100.1 #客户端自动获取的网关ip
[R1-ip-pool-pool_1]lease day 10 #租期10天
[R1-ip-pool-pool_1]network 192.168.100.1 mask 24 #客户端获取到的ip网段和子网掩码
[R1-ip-pool-pool_1]excluded-ip-address 192.168.100.2 #预留ip
[R1-ip-pool-pool_1]excluded-ip-address 192.168.100.100 192.168.100.150 #预留ip段
[R1-ip-pool-pool_1]qu
[R1]ip pool pool_2
Info: It's successful to create an IP address pool.
[R1-ip-pool-pool_2]network 192.168.200.1 mask 24
[R1-ip-pool-pool_2]gateway-list 192.168.200.100
[R1-ip-pool-pool_2]dns-list 192.168.200.101
[R1-ip-pool-pool_2]lease day 10
在接口上面启用全局dhcp
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]dhcp select global
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]dhcp select global
在PC1上查看开启自动获取ip的客户端
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe4f:191b
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.100.254
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.100.1
Physical address..................: 54-89-98-4F-19-1B
DNS server........................: 192.168.100.2
在PC2上查看开启自动获取ip的客户端
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fea2:458c
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.200.254
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.200.100
Physical address..................: 54-89-98-A2-45-8C
DNS server........................: 192.168.200.101
接口DHCP配置
在R1的G0/0/2接口上开启接口dhcp服务(接口dhcp服务分配的ip网段与接口的ip相同,子网掩码也与接口子网掩码相同)
[R1]interface GigabitEthernet 0/0/2
[R1-GigabitEthernet0/0/2]ip address 192.168.130.1 24
[R1-GigabitEthernet0/0/2]dhcp select interface
[R1-GigabitEthernet0/0/2]dhcp server excluded-ip-address 192.168.130.18 #保留ip地址
[R1-GigabitEthernet0/0/2]dhcp server excluded-ip-address 192.168.130.20 192.168.130.130 #保留ip地址段
[R1-GigabitEthernet0/0/2]dhcp server dns-list 192.168.130.12 #dns设置
[R1-GigabitEthernet0/0/2]dhcp server lease day 12 #租期12天
查看PC3是否获取到ip地址
Link local IPv6 address...........: fe80::5689:98ff:fe40:312e
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.130.254
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.130.1
Physical address..................: 54-89-98-40-31-2E
DNS server........................: