DHCP中继

拓扑图:

交换机配置:

<Huawei>system-view 
[Huawei]sysname sw1

[sw1]v b 10 20
[sw1]int e0/0/1
[sw1-Ethernet0/0/1]p l a
[sw1-Ethernet0/0/1]p d v 10
[sw1-Ethernet0/0/1]un sh

[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

[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

[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

[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]un sh

路由器R1配置:

<Huawei>system-view 
[Huawei]sysname R1

[R1]dhcp enable 
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 14.0.0.2 24
[R1-GigabitEthernet0/0/0]dhcp select global 
[R1-GigabitEthernet0/0/0]un sh
[R1-GigabitEthernet0/0/0]q

[R1]ip route-static 0.0.0.0 0.0.0.0 14.0.0.1

[R1]ip pool dhcp15
[R1-ip-pool-dhcp15]network 15.0.0.1 mask 24            //不配的话获取不到IP
[R1-ip-pool-dhcp15]gateway-list 15.0.0.1	
[R1-ip-pool-dhcp15]dns-list 8.8.8.8 2.2.2.2
[R1-ip-pool-dhcp15]excluded-ip-address 15.0.0.100 15.0.0.254          //排除地址段
[R1-ip-pool-dhcp15]static-bind ip-address 15.0.0.88 mac-address 5489-98EF-383F      
//分配固定IP
[R1-ip-pool-dhcp15]q

[R1]ip pool dhcpvlan10
[R1-ip-pool-dhcpvlan10]network 192.168.10.0 mask 24
[R1-ip-pool-dhcpvlan10]gateway-list 192.168.10.1
[R1-ip-pool-dhcpvlan10]dns-list 8.8.8.8 2.2.2.2
[R1-ip-pool-dhcpvlan10]q
	
[R1]ip pool dhcpvlan20	
[R1-ip-pool-dhcpvlan20]network 192.168.20.0 mask 24	
[R1-ip-pool-dhcpvlan20]gateway-list 192.168.20.1
[R1-ip-pool-dhcpvlan20]dns-list 8.8.8.8 2.2.2.2
[R1-ip-pool-dhcpvlan20]q

路由器R2配置:

<Huawei>system-view 
[Huawei]sysname R2
[R2]dhcp enable 

[R2]int g0/0/1.10
[R2-GigabitEthernet0/0/1.10]d t v 10
[R2-GigabitEthernet0/0/1.10]ip add 192.168.10.1 24
[R2-GigabitEthernet0/0/1.10]a b en
[R2-GigabitEthernet0/0/1.10]dhcp select relay 
[R2-GigabitEthernet0/0/1.10]dhcp relay server-ip 14.0.0.2
[R2-GigabitEthernet0/0/1.10]q

[R2]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 en
[R2-GigabitEthernet0/0/1.20]dhcp select relay 
[R2-GigabitEthernet0/0/1.20]dhcp relay server-ip 14.0.0.2
[R2-GigabitEthernet0/0/1.20]q

[R2]int g0/0/2
[R2-GigabitEthernet0/0/2]ip add 14.0.0.1 24
[R2-GigabitEthernet0/0/2]un sh
[R2-GigabitEthernet0/0/2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.0.0.1 24
[R2-GigabitEthernet0/0/0]un sh
[R2-GigabitEthernet0/0/0]q
	
[R2]ip route-static 15.0.0.0 24 12.0.0.2

路由器R3配置:

<Huawei>system-view 
[Huawei]sysname R3

[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[R3-GigabitEthernet0/0/0]un sh	
[R3-GigabitEthernet0/0/0]q

[R3]dhcp enable 
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 15.0.0.1 24
[R3-GigabitEthernet0/0/1]dhcp select relay 	
[R3-GigabitEthernet0/0/1]dhcp relay server-ip 14.0.0.2
[R3-GigabitEthernet0/0/1]q
	
[R3]ip route-static 0.0.0.0 0.0.0.0 12.0.0.1

[R3]ping 12.0.0.1
  PING 12.0.0.1: 56  data bytes, press CTRL_C to break
    Reply from 12.0.0.1: bytes=56 Sequence=1 ttl=255 time=80 ms
    Reply from 12.0.0.1: bytes=56 Sequence=2 ttl=255 time=50 ms
    Reply from 12.0.0.1: bytes=56 Sequence=3 ttl=255 time=50 ms
    Reply from 12.0.0.1: bytes=56 Sequence=4 ttl=255 time=40 ms
    Reply from 12.0.0.1: bytes=56 Sequence=5 ttl=255 time=30 ms

  --- 12.0.0.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 30/50/80 ms

[R3]ping 14.0.0.1
  PING 14.0.0.1: 56  data bytes, press CTRL_C to break
    Reply from 14.0.0.1: bytes=56 Sequence=1 ttl=255 time=40 ms
    Reply from 14.0.0.1: bytes=56 Sequence=2 ttl=255 time=1 ms
    Reply from 14.0.0.1: bytes=56 Sequence=3 ttl=255 time=20 ms
    Reply from 14.0.0.1: bytes=56 Sequence=4 ttl=255 time=40 ms
    Reply from 14.0.0.1: bytes=56 Sequence=5 ttl=255 time=50 ms

  --- 14.0.0.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 1/30/50 ms

[R3]ping 14.0.0.2
  PING 14.0.0.2: 56  data bytes, press CTRL_C to break
    Reply from 14.0.0.2: bytes=56 Sequence=1 ttl=254 time=90 ms
    Reply from 14.0.0.2: bytes=56 Sequence=2 ttl=254 time=40 ms
    Reply from 14.0.0.2: bytes=56 Sequence=3 ttl=254 time=60 ms
    Reply from 14.0.0.2: bytes=56 Sequence=4 ttl=254 time=60 ms
    Reply from 14.0.0.2: bytes=56 Sequence=5 ttl=254 time=60 ms

  --- 14.0.0.2 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 40/62/90 ms

去PC机获取IP地址:

在PC5上进行测试,证明全网互通:

PC>ping 192.168.10.254

Ping 192.168.10.254: 32 data bytes, Press Ctrl_C to break
From 192.168.10.254: bytes=32 seq=1 ttl=126 time=172 ms
From 192.168.10.254: bytes=32 seq=2 ttl=126 time=78 ms
From 192.168.10.254: bytes=32 seq=3 ttl=126 time=47 ms
From 192.168.10.254: bytes=32 seq=4 ttl=126 time=94 ms
From 192.168.10.254: bytes=32 seq=5 ttl=126 time=78 ms

--- 192.168.10.254 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 47/93/172 ms

PC>ping 192.168.10.253

Ping 192.168.10.253: 32 data bytes, Press Ctrl_C to break
From 192.168.10.253: bytes=32 seq=1 ttl=126 time=235 ms
From 192.168.10.253: bytes=32 seq=2 ttl=126 time=78 ms
From 192.168.10.253: bytes=32 seq=3 ttl=126 time=109 ms
From 192.168.10.253: bytes=32 seq=4 ttl=126 time=78 ms
From 192.168.10.253: bytes=32 seq=5 ttl=126 time=78 ms

--- 192.168.10.253 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 78/115/235 ms

PC>ping 192.168.20.253

Ping 192.168.20.253: 32 data bytes, Press Ctrl_C to break
From 192.168.20.253: bytes=32 seq=1 ttl=126 time=203 ms
From 192.168.20.253: bytes=32 seq=2 ttl=126 time=79 ms
From 192.168.20.253: bytes=32 seq=3 ttl=126 time=78 ms
From 192.168.20.253: bytes=32 seq=4 ttl=126 time=93 ms
From 192.168.20.253: bytes=32 seq=5 ttl=126 time=63 ms

--- 192.168.20.253 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 63/103/203 ms

PC>ping 192.168.20.254

Ping 192.168.20.254: 32 data bytes, Press Ctrl_C to break
From 192.168.20.254: bytes=32 seq=1 ttl=126 time=219 ms
From 192.168.20.254: bytes=32 seq=2 ttl=126 time=78 ms
From 192.168.20.254: bytes=32 seq=3 ttl=126 time=62 ms
From 192.168.20.254: bytes=32 seq=4 ttl=126 time=78 ms
From 192.168.20.254: bytes=32 seq=5 ttl=126 time=78 ms

--- 192.168.20.254 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 62/103/219 ms

PC>

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值