作者:兔砸网工-抑郁的狼
1.LSW1中的G0/0/2接口使用接口地址池方式给PC3分配IP地址
2.VLANif10与VLANif20使用全局地址池,地址池命名: ip pool vlan10,AR1作为DHCP代理。SW1需保证发送offer消息能到10.1.4.0网段,使用全局地址池注意:AR1配置缺省路由实现所有主机通信。
实验拓扑图如下:
LSW1创建VLAN并绑定所属端口
[LSW1]vlan batch 10 20 30 12
[LSW1]interface GigabitEthernet 0/0/1
[LSW1-GigabitEthernet0/0/1]port link-type trunk
[LSW1-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20
[LSW1]interface GigabitEthernet 0/0/2
[LSW1-GigabitEthernet0/0/2]port link-type access
[LSW1-GigabitEthernet0/0/2]port default vlan 30
[LSW1]interface GigabitEthernet 0/0/3
[LSW1-GigabitEthernet0/0/3]port link-type access
[LSW1-GigabitEthernet0/0/3]port default vlan 12
LSW2创建VLAN并绑定所属端口
[LSW2]vlan batch 10 20
[LSW2]interface Ethernet0/0/1
[LSW2- Ethernet0/0/1]port link-type trunk
[LSW2- Ethernet0/0/1]port trunk allow-pass vlan 10 20
[LSW2]interface Ethernet0/0/2
[LSW2- Ethernet0/0/2]port link-type access
[LSW1- Ethernet0/0/2]port default vlan 10
[LSW2]interface Ethernet0/0/3
[LSW2- Ethernet0/0/3]port link-type access
[LSW1- Ethernet0/0/3]port default vlan 20
LSW1配置IP地址
[LSW1]interface vlan 10
[LSW1-Vlanif10]ip address 10.1.1.254 255.255.255.0
[LSW1]interface vlan 12
[LSW1-Vlanif12]ip address 10.1.12.1 255.255.255.0
[LSW1]interface vlan 20
[LSW1-Vlanif20]ip address 10.1.2.254 255.255.255.0
[LSW1]interface vlan 30
[LSW1-Vlanif30]ip address 10.1.3.254 255.255.255.0
AR1配置IP地址
[AR1]int GigabitEthernet 0/0/0
[AR1-GigabitEthernet0/0/0] ip address 10.1.12.2 255.255.255.0
[AR1]int GigabitEthernet 0/0/1
[AR1-GigabitEthernet0/0/1] ip address 10.1.4.254 255.255.255.0
[LSW1]dhcp enable
[LSW1]interface vlan 30
[LSW1] dhcp select interface
[LSW1] dhcp server excluded-ip-address 10.1.3.101 10.1.3.253
[LSW1] ip pool pc2
[LSW1] gateway-list 10.1.1.254
[LSW1] network 10.1.1.0 mask 255.255.255.0
[LSW1] ip pool pc3
[LSW1] network 10.1.2.0 mask 255.255.255.0
[LSW1] static-bind ip-address 10.1.2.88 mac-address 5489-9837-3e51 #根据MAC地址给指定的PC分配IP地址
[LSW1] ip pool pc4
[LSW1] gateway-list 10.1.4.254
[LSW1] network 10.1.4.0 mask 255.255.255.0
[LSW1] interface Vlanif10
[LSW1] dhcp select global
[LSW1] interface Vlanif12
[LSW1] dhcp select globa
[LSW1] interface Vlanif20
[LSW1] dhcp select global
[AR1]dhcp enable
[AR1]interface GigabitEthernet 0/0/1
[AR1-GigabitEthernet0/0/1]dhcp select relay
[AR1-GigabitEthernet0/0/1]dhcp relay server-ip 10.1.12.1
[LSW1] ip route-static 10.1.4.0 255.255.255.0 10.1.12.2
[AR1] ip route-static 0.0.0.0 0.0.0.0 10.1.12.1
PC1获取IP地址
PC3获取IP地址
1.客户端广播方式发送discover报文,找寻服务器
2.服务器收到discover报文后,单播方式发送offer消息,将10.1.3.100分配给客户端
3.客户端收到offer,申请使用该地址,并告知其他DHCP服务器,已经选择哪台服务器来获取地址
4.服务器收到之后,确认所提供的IP地址
5.客户端收到ACK后,发送3次免费ARP,确认无主机使用此地址,才开始使用该地址进行通信
sysname LSW1
vlan batch 10 12 20 30
dhcp enable
diffserv domain default
drop-profile default
ip pool pc2
gateway-list 10.1.1.254
network 10.1.1.0 mask 255.255.255.0
ip pool pc3
gateway-list 10.1.2.254
network 10.1.2.0 mask 255.255.255.0
static-bind ip-address 10.1.2.88 mac-address 5489-9837-3e51
ip pool pc4
gateway-list 10.1.4.254
network 10.1.4.0 mask 255.255.255.0
interface Vlanif10
ip address 10.1.1.254 255.255.255.0
dhcp select global
interface Vlanif12
ip address 10.1.12.1 255.255.255.0
dhcp select global
interface Vlanif20
ip address 10.1.2.254 255.255.255.0
dhcp select global
interface Vlanif30
ip address 10.1.3.254 255.255.255.0
dhcp select interface
dhcp server excluded-ip-address 10.1.3.101 10.1.3.253
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20
interface GigabitEthernet0/0/2
port link-type access
port default vlan 30
interface GigabitEthernet0/0/3
port link-type access
port default vlan 12
ip route-static 10.1.4.0 255.255.255.0 10.1.12.2
sysname LSW2
vlan batch 10 20
interface Ethernet0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20
interface Ethernet0/0/2
port link-type access
port default vlan 10
interface Ethernet0/0/3
port link-type access
sysname AR1
dhcp enable
interface GigabitEthernet0/0/0
ip address 10.1.12.2 255.255.255.0
interface GigabitEthernet0/0/1
ip address 10.1.4.254 255.255.255.0
dhcp select relay
dhcp relay server-ip 10.1.12.1
ip route-static 0.0.0.0 0.0.0.0 10.1.12.1