理论+实验——(Linux网络)DHCP原理与配 置

一、了解DNCP服务

在这里插入图片描述
使用DHCP的好处:

  • 减少管理员的工作量
  • 避免输入错误的可能
  • 避免IP地址冲突
  • 当更改IP地址段时,不需要重新分配每个用户的IP地址
  • 提高了IP地址的利用率
  • 方便客户端的配置

DHCP的分配方式:

  • 自动分配:分配到一个IP地址后永久使用
  • 手动分配:由DHCP服务器管理员专门指定IP地址
  • 动态分配:使用完后释放该IP,供其他客户机使用

二、DHCP的租约过程

在这里插入图片描述在这里插入图片描述

三、DHCP服务器的配置

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述

四、DHCP客户端的配置

在这里插入图片描述在这里插入图片描述

五、DHCP中继原理与配置

在这里插入图片描述
DHCP配置文件

vi /etc/dhcp/dhcp.conf

ddns-update-style none;
subnet 192.168.100.0 netmask 255.255.255.0 {
    
    
range 192.168.100.100 192.168.100.200;
option routers 192.168.100.1;
option subnet-mask 255.255.255.0;
option domain-name "www.bdqn.com";
option domain-name-servers 114.114.114.114 8.8.8.8;
option broadcast-address 192.168.100.255;
default-lease-time 21600;
max-lease-time 43200;
host prtsvr {
    
    
hardware ethernet 00:0C:29:BC:CF:2F;   ###第二台客户机的MAC地址
fixed-address 192.168.100.66;
  }
}

#ddns-update-style none;
subnet 192.168.10.0 netmask 255.255.255.0 {
    
    
range 192.168.10.100 192.168.10.200;
option routers 192.168.10.1;
option subnet-mask 255.255.255.0;
option domain-name "www.bdqn1.com";
#option domain-name-servers 114.114.114.114 8.8.8.8;
#option broadcast-address 192.168.100.255;
default-lease-time 21600;
max-lease-time 43200;
#host prtsvr {
    
    
#hardware ethernet 00:0C:29:BC:CF:2F;   ###第二台客户机的MAC地址
#fixed-address 192.168.100.66;
#  }
}

#ddns-update-style none;
subnet 192.168.20.0 netmask 255.255.255.0 {
    
    
range 192.168.20.100 192.168.20.200;
option routers 192.168.20.1;
option subnet-mask 255.255.255.0;
option domain-name "www.bdqn2.com";
#option domain-name-servers 114.114.114.114 8.8.8.8;
#option broadcast-address 192.168.100.255;
default-lease-time 21600;
max-lease-time 43200;
#host prtsvr {
    
    
#hardware ethernet 00:0C:29:BC:CF:2F;   ###第二台客户机的MAC地址
#fixed-address 192.168.100.66;
#  }
}

拓扑图配置

SW2

<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SW2
[SW2]v b 10 20 30
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW2]int e0/0/1
[SW2-Ethernet0/0/1]p l a
[SW2-Ethernet0/0/1]p d v 10
[SW2-Ethernet0/0/1]un sh
Info: Interface Ethernet0/0/1 is not shutdown.
[SW2-Ethernet0/0/1]int e0/0/2
[SW2-Ethernet0/0/2]p l a
[SW2-Ethernet0/0/2]p d v 20
[SW2-Ethernet0/0/2]un sh
Info: Interface Ethernet0/0/2 is not shutdown.
[SW2-Ethernet0/0/2]int e0/0/3
[SW2-Ethernet0/0/3]p l a
[SW2-Ethernet0/0/3]p d v 30
[SW2-Ethernet0/0/3]un sh
Info: Interface Ethernet0/0/3 is not shutdown.
[SW2-Ethernet0/0/3]int g0/0/1
[SW2-GigabitEthernet0/0/1]p l a
[SW2-GigabitEthernet0/0/1]p l t
[SW2-GigabitEthernet0/0/1]p t a v a
[SW2-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[SW2-GigabitEthernet0/0/1]q
[SW2]
RSW1

<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname RWS1
[RWS1]dhcp enable 
Info: The operation may take a few seconds. Please wait for a moment.done.
[RWS1]v b 10 20 30
Info: This operation may take a few seconds. Please wait for a moment...done.
[RWS1]int g0/0/1
[RWS1-GigabitEthernet0/0/1]p l t
[RWS1-GigabitEthernet0/0/1]p t a v a
[RWS1-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[RWS1-GigabitEthernet0/0/1]q	
[RWS1]int Vlanif 10
[RWS1-Vlanif10]ip add 192.168.10.1 24
[RWS1-Vlanif10]dhcp select relay 	
[RWS1-Vlanif10]dhcp relay server-ip 192.168.100.10
[RWS1-Vlanif10]q	
[RWS1]int Vlanif 20
[RWS1-Vlanif20]ip add 192.168.20.1 24
[RWS1-Vlanif20]dhcp select relay 
[RWS1-Vlanif20]dhcp relay server-ip 192.168.100.10
[RWS1-Vlanif20]q	
[RWS1]int Vlanif 30
[RWS1-Vlanif30]ip add 192.168.100.1 24
[RWS1-Vlanif30]q
[RWS1]ping 192.168.100.10
  PING 192.168.100.10: 56  data bytes, press CTRL_C to break
    Reply from 192.168.100.10: bytes=56 Sequence=1 ttl=64 time=50 ms
    Reply from 192.168.100.10: bytes=56 Sequence=2 ttl=64 time=50 ms
    Reply from 192.168.100.10: bytes=56 Sequence=3 ttl=64 time=50 ms
    Reply from 192.168.100.10: bytes=56 Sequence=4 ttl=64 time=60 ms

  --- 192.168.100.10 ping statistics ---
    4 packet(s) transmitted
    4 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 50/52/60 ms

[RWS1]ping 192.168.100.10
  PING 192.168.100.10: 56  data bytes, press CTRL_C to break
    Reply from 192.168.100.10: bytes=56 Sequence=1 ttl=64 time=110 ms
    Reply from 192.168.100.10: bytes=56 Sequence=2 ttl=64 time=70 ms
    Reply from 192.168.100.10: bytes=56 Sequence=3 ttl=64 time=60 ms
    Reply from 192.168.100.10: bytes=56 Sequence=4 ttl=64 time=50 ms
    Reply from 192.168.100.10: bytes=56 Sequence=5 ttl=64 time=50 ms

  --- 192.168.100.10 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 50/68/110 ms

猜你喜欢

转载自blog.csdn.net/ZG_66/article/details/107734248
今日推荐