跳轉到內容

LPI Linux 認證/DHCP 配置

來自華夏公益教科書,自由的教科書

詳細目標 (210.1)

[編輯 | 編輯原始碼]

(LPIC-2 版本 4.5)


權重 2


描述: 考生應能夠配置 DHCP 伺服器。此目標包括設定預設和每個客戶端選項、新增靜態主機和 BOOTP 主機。還包括配置 DHCP 中繼代理和維護 DHCP 伺服器。


關鍵知識領域

  • DHCP 配置檔案、術語和實用程式。
  • 子網和動態分配範圍設定。
  • 瞭解 DHCPv6 和 IPv6 路由器廣告


術語和實用程式

  • dhcpd.conf
  • dhcpd.leases
  • DHCP 日誌訊息在 syslog 或 systemd 日誌中
  • arp
  • dhcpd
  • radvd
  • radvd.conf

DHCP 配置 =

[編輯 | 編輯原始碼]

描述: 考生應能夠配置 DHCP 伺服器並設定預設選項、建立子網和建立動態分配範圍。此目標包括新增靜態主機、為單個主機設定選項以及新增 bootp 主機。還包括配置 DHCP 中繼代理,並在進行更改後重新載入 DHCP 伺服器。

關鍵檔案術語實用程式包括

dhcpd.conf 
dhcpd.leases

大多數閱讀本文的人可能已經瞭解 DHCP 協議。簡單提醒一下,DHCP 代表動態主機配置協議,通常用於在網路中分發特定的網路設定。例如,預設閘道器、名稱伺服器、IP 地址等等。

為了簡單說明該協議本身。

<在此插入有關 DHCP 請求的示意圖>

配置 dhcpd

[編輯 | 編輯原始碼]

在安裝 dhcpd 後,主配置檔案位於 /etc/dhcpd.conf。對於 Debian 安裝,應在安裝完成後立即編輯 /etc/default/dhcp,並根據您的設定更改以下行。

INTERFACES="eth1" # or "eth1 eth2", whatever interfaces you wish to serve ip's.

dhcpd.conf 檔案分為全域性引數和特定於子網的引數。每個子網都可以覆蓋全域性引數。最常用的引數如下所示。

option domain-name "example.com"; 
option domain-name-servers "192.168.0.1, 193.190.63.172"
option subnet-mask 255.255.255.0; # global Subnet mask
default-lease-time 600; # Seconds each DHCP lease is granted and after which a request for the same ip is launched.
max-lease-time 7200; # If DHCP server does not respond, keep IP till 7200 seconds are passed.

subnet 192.168.0.0 netmask 255.255.255.240 { # Subnet for first 13 devices, 10 of which are servers, 3 printers
 range 192.168.0.10 192.168.0.13;  # Range of IP's for our printers
 option subnet-mask 255.255.255.240;
 option broadcast-address 192.168.0.15; # This is the subnets broadcast address
 option routers 192.168.0.14; # The gateway of this subnet
 option time-servers 192.168.0.14; # Gateway is running a timeserver
 option ntp-servers 192.168.0.14; # Gateway running a timeserver
}
subnet 192.168.0.16 netmask 255.255.255.224 { # Subnet for 29 computers
 range 192.168.0.17 192.168.0.45;
 option subnet-mask 255.255.255.224;
 option broadcast-address 192.168.0.47;
 option routers 192.168.0.46;
}
group {
 host server1 { # the first fixed server for subnet 192.168.0.0/28
  server-name server1;
  hardware ethernet 0f:45:d3:23:11:90;
  fixed-address 192.168.0.1;
 }
 host server2 {
  server-name server2;
  hardware ethernet 0f:45:d3:23:11:91;
  fixed-address 192.168.0.2;
 }
}

此示例只是提供有關可能選項和覆蓋的提示。

有關 dhcpd.conf 和 dhcp-options 的更多資訊,請參閱手冊頁。在這些頁面中也查詢有關使用 DHCP 伺服器為 BOOTP 提供服務的資訊,這對於無盤客戶端很有用。


華夏公益教科書