理論+実験-(Linuxネットワーク)DHCPの原理と構成

1. DNCPサービスを理解する

ここに画像の説明を挿入
DHCPを使用する利点:

  • 管理者の作業負荷を軽減
  • 入力エラーの可能性を回避する
  • IPアドレスの競合を回避する
  • IPアドレスセグメントを変更する場合、各ユーザーのIPアドレスを再割り当てする必要はありません
  • IPアドレスの使用率の向上
  • 便利なクライアント構成

DHCP配布方法:

  • 自動割り当て:IPアドレスが割り当てられた後の永続的な使用
  • 手動割り当て:IPアドレスはDHCPサーバー管理者によって指定されます
  • 動的割り当て:他のクライアントが使用できるように、使用後にIPを解放します

2、DHCPリースプロセス

ここに画像の説明を挿入ここに画像の説明を挿入

3、DHCPサーバーの構成

ここに画像の説明を挿入
ここに画像の説明を挿入
ここに画像の説明を挿入ここに画像の説明を挿入ここに画像の説明を挿入ここに画像の説明を挿入ここに画像の説明を挿入

4、DHCPクライアント構成

ここに画像の説明を挿入ここに画像の説明を挿入

5、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