DHCP中继应用场景:
通常在DHCP分配网段过多的情况下,网关路由器上配置DHCP服务压力过大,用路由器或第二台DHCP服务器来分担业务。
以下通过一个实验诠释DHCP中继的配置:
LSW1
<Huawei>
<Huawei>un te m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys SW1
[SW1]int e0/0/1
[SW1-Ethernet0/0/1]q
[SW1]vlan b 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW1]int e0/0/1
[SW1-Ethernet0/0/1]port link-type access
[SW1-Ethernet0/0/1]port default vlan 10
[SW1-Ethernet0/0/1]un sh
Info: Interface Ethernet0/0/1 is not shutdown.
[SW1-Ethernet0/0/1]int e0/0/2
[SW1-Ethernet0/0/2]p l a
[SW1-Ethernet0/0/2]p d v 20
[SW1-Ethernet0/0/2]un sh
Info: Interface Ethernet0/0/2 is not shutdown.
[SW1-Ethernet0/0/2]int e0/0/3
[SW1-Ethernet0/0/3]p l a
[SW1-Ethernet0/0/3]p d v 10
[SW1-Ethernet0/0/3]un sh
Info: Interface Ethernet0/0/3 is not shutdown.
[SW1-Ethernet0/0/3]int e0/0/4
[SW1-Ethernet0/0/4]p l a
[SW1-Ethernet0/0/4]p d v 20
[SW1-Ethernet0/0/4]un sh
Info: Interface Ethernet0/0/4 is not shutdown.
[SW1-Ethernet0/0/4]int g0/0/1
[SW1-GigabitEthernet0/0/1]p l t
[SW1-GigabitEthernet0/0/1]p t a v a
[SW1-GigabitEthernet0/0/1]q
R1
<Huawei>un te m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R1
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 14.0.0.2 24
[R1-GigabitEthernet0/0/0]dhcp se
[R1-GigabitEthernet0/0/0]dhcp select gl
[R1-GigabitEthernet0/0/0]dhcp select global
Error: Please enable DHCP in the global view first.
[R1-GigabitEthernet0/0/0]q
[R1]dhcp en
[R1]dhcp enable ##开启DHCP服务
Info: The operation may take a few seconds. Please wait for a moment.done.
[R1]in g0/0/0
[R1-GigabitEthernet0/0/0]dhcp select global(请求DHCP服务)
[R1-GigabitEthernet0/0/0]q
[R1]ip pool DHCP(设置地址池)
[R1]ip pool DHCP15.0.0.0
Info: It's successful to create an IP address pool.
[R1-ip-pool-DHCP15.0.0.0]netw
[R1-ip-pool-DHCP15.0.0.0]network 15.0.0.0 m 24(设置网段)
[R1-ip-pool-DHCP15.0.0.0]gate
[R1-ip-pool-DHCP15.0.0.0]gateway-list 15.0.0.1(设置网关)
[R1-ip-pool-DHCP15.0.0.0]dns
[R1-ip-pool-DHCP15.0.0.0]dns-list 8.8.8.8 2.2.2.2(设置dns)
[R1-ip-pool-DHCP15.0.0.0]q
[R1]ip pool DHCPvlan10
Info: It's successful to create an IP address pool.
[R1-ip-pool-DHCPvlan10]netw
[R1-ip-pool-DHCPvlan10]network 192.168.10.0 m 24
[R1-ip-pool-DHCPvlan10]gat
[R1-ip-pool-DHCPvlan10]gateway-list 192.168.10.1
[R1-ip-pool-DHCPvlan10]dns
[R1-ip-pool-DHCPvlan10]dns-list 8.8.8.8 2.2.2.2
[R1-ip-pool-DHCPvlan10]q
[R1]ip pool DHCP
[R1]ip pool DHCPVLAN20
Info: It's successful to create an IP address pool.
[R1-ip-pool-DHCPVLAN20]netw
[R1-ip-pool-DHCPVLAN20]network 192.168.20.0 m 24
[R1-ip-pool-DHCPVLAN20]gat
[R1-ip-pool-DHCPVLAN20]gateway-list 192.168.20.1
[R1-ip-pool-DHCPVLAN20]dns
[R1-ip-pool-DHCPVLAN20]dns-list 8.8.8.8 2.2.2.2
[R1-ip-pool-DHCPVLAN20]q
[R1]ip route-s
[R1]ip route-static 0.0.0.0 0.0.0.0 14.0.0.1
R2
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R2
[R2]q
<R2>un te m
Info: Current terminal monitor is off.
<R2>sys
Enter system view, return user view with Ctrl+Z.
[R2]int g0/0/2
[R2-GigabitEthernet0/0/2]ip add 14.0.0.1 24
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.0.0.1 24
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R2-GigabitEthernet0/0/1]int g0/0/1.10
[R2-GigabitEthernet0/0/1.10]dot1q termination vid 10(该接口属于vlan10)
[R2-GigabitEthernet0/0/1.10]ip add 192.168.10.1 24
[R2-GigabitEthernet0/0/1.10]arp broadcast enable(开启arp广播)
[R2-GigabitEthernet0/0/1.10]un sh
Info: Interface GigabitEthernet0/0/1.10 is not shutdown.
[R2-GigabitEthernet0/0/1.10]int g0/0/1.20
[R2-GigabitEthernet0/0/1.20]d t v 20
[R2-GigabitEthernet0/0/1.20]ip add 192.168.20.1 24
[R2-GigabitEthernet0/0/1.20]a b e
[R2-GigabitEthernet0/0/1.20]un sh
Info: Interface GigabitEthernet0/0/1.20 is not shutdown.
[R2-GigabitEthernet0/0/1.20]q
[R2]dhcp en
[R2]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[R2]int g0/0/1.10(子接口下宣告DHCP中继)
[R2-GigabitEthernet0/0/1.10]dhcp se
[R2-GigabitEthernet0/0/1.10]dhcp select ?
global Local server
interface Interface server pool
relay DHCP relay(选择relay)
[R2-GigabitEthernet0/0/1.10]dhcp select relay(基于DHCP中继)
[R2-GigabitEthernet0/0/1.10]dhcp re
[R2-GigabitEthernet0/0/1.10]dhcp relay se
[R2-GigabitEthernet0/0/1.10]dhcp relay server-ip 14.0.0.2
[R2-GigabitEthernet0/0/1.10]int g0/0/1.20
[R2-GigabitEthernet0/0/1.20]dhcp sel
[R2-GigabitEthernet0/0/1.20]dhcp select re
[R2-GigabitEthernet0/0/1.20]dhcp select relay
[R2-GigabitEthernet0/0/1.20]d r s 14.0.0.2
[R2-GigabitEthernet0/0/1.20]un sh
Info: Interface GigabitEthernet0/0/1.20 is not shutdown.
[R2-GigabitEthernet0/0/1.20]q
[R2]ip route-s
[R2]ip route-static 15.0.0.1 24 12.0.0.2(设置静态路由)
R3
<R3>sys
Enter system view, return user view with Ctrl+Z.
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[R3-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R3-GigabitEthernet0/0/0]q
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]q
[R3]dhcp en
[R3]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 15.0.0.1 24
[R3-GigabitEthernet0/0/1]dhcp sel
[R3-GigabitEthernet0/0/1]dhcp select re
[R3-GigabitEthernet0/0/1]dhcp select relay
[R3-GigabitEthernet0/0/1]dhcp re
[R3-GigabitEthernet0/0/1]dhcp relay se
[R3-GigabitEthernet0/0/1]dhcp relay server-ip 14.0.0.2
[R3-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R3-GigabitEthernet0/0/1]q
[R3]ip ro
[R3]ip route-static 0.0.0.0 0.0.0.0 12.0.0.1(设置默认路由)
设置结束后,打开PC5,设置获取ip检验