企业通过dhcp中继自动获取ip地址
交换机LSW1配置如下:
[LSW1]dis cu
#
sysname LSW1
#
undo info-center enable
#
vlan batch 10 20 30
#
dhcp enable
#
interface Vlanif10
ip address 192.168.10.254 255.255.255.0
dhcp select relay
dhcp relay server-ip 192.168.100.1
#
interface Vlanif20
ip address 192.168.20.254 255.255.255.0
dhcp select relay
dhcp relay server-ip 192.168.100.1
#
interface Vlanif30
ip address 192.168.100.254 255.255.255.0
#
interface GigabitEthernet0/0/1
port link-type access
port default vlan 10
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 20
#
interface GigabitEthernet0/0/3
port link-type access
port default vlan 30
AR1配置如下:
<AR1>dis cu
#
sysname AR1
#
dhcp enable
#
ip pool v10
gateway-list 192.168.10.254
network 192.168.10.0 mask 255.255.255.0
static-bind ip-address 192.168.10.200 mac-address 5489-9803-2471
dns-list 8.8.8.8
#
ip pool v20
gateway-list 192.168.20.254
network 192.168.20.0 mask 255.255.255.0
excluded-ip-address 192.168.20.100 192.168.20.253
lease day 8 hour 0 minute 0
dns-list 114.114.114.114
#
interface GigabitEthernet0/0/0
ip address 192.168.100.1 255.255.255.0
dhcp select global
#
ip route-static 0.0.0.0 0.0.0.0 192.168.100.254
验证一下是否可以用过dhcp中继获取到地址,实验现象如下,实验完成。
我们看一下pc3也可以通过dhcp获得ip地址
我们可以通过命令:display ip pool v10 used 看到自动获取ip地址的ip以及对应的mac,被使用的ip数为3个。
特定的mac地址绑定特定的ip:
这里我们想把192.168.10.200这个地址固定分给pc1用,其他人不能用,用这条命令绑定即可 static-bind ip-address 192.168.10.200 mac-address 5489-9803-2471