วิธีการติดตั้งและคอนฟิก DHCP Server บนลินุกซ์
ระบบที่ทดสอบ
- Fedora 8
- dhcp-3.0.6-12.fc8.i386.rpm
คอนฟิกพื้นฐานของ Server
- IP Address: 192.168.1.1
- Subbet Mask: 255.255.255.0
ตัวอย่างไฟล์คอนฟิก /etc/dhcpd.conf
# /etc/dhcpd.conf
authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
option domain-name "your-domain.com";
option domain-name-servers 192.168.1.1;
range dynamic-bootp 192.168.1.101 192.168.1.200;
default-lease-time 21600;
max-lease-time 43200;
}
host fixip-client1 {
hardware ethernet 00:0c:11:22:33:44;
fixed-address 192.168.1.11;
}
จากตัวอย่าง DHCP Server เครื่องนี้จะให้ข้อมูลเกี่ยวกับ IP configuration ยัง client ที่ตั้งค่าเป็น DCHP ดังต่อไปนี้
- จะแจก ip address (range dynamic-bootp) ตั้งแต่ 192.168.1.101 ถึง 192.168.1.200
- Subnet mask (option subnet-mask)จะเป็น 255.255.255.0
- domain-name (option domain-name-servers) เป็น your-domain.com
- DNS Server (option domain-name-servers) คือ 192.168.1.1
- Default Gateway (option routers) เป็น 192.168.1.1
สำหรับเครื่องที่มี MAC Address “00:0c:11:22:33:44” จะได้รับ ip เป็น 192.168.1.11
Start DHCP Server
ใช้คำสั่ง service เพื่อ start DHCP Server
[root@server etc]# service dhcpd start Starting dhcpd: [ OK ]
การทดสอบ
บนเครื่อง client ที่เป็น Windows เราสามารถใช้คำสั่ง ipconfig ในการทดสอบ DHCP
C:\Documents and Settings\user\ipconfig
Windows IP Configuration
Ethernet adapter LAN - Broadcom:
Connection-specific DNS Suffix . : your-domain.com
IP Address. . . . . . . . . . . . : 192.168.1.200
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
Stop DHCP Server
ใช้คำสั่ง service เพื่อ stop DHCP Server
[root@server etc]# service dhcpd stop Shutting down dhcpd: [ OK ]
ข้อมูลอ้างอิง