10/01/2560

ติดตั้ง DHCP Server บน CentOS

วิธีติดตั้ง DHCP Server บน CentOS 6 มีไม่กี่ขั้นตอนง่ายๆ ดังนี้ครับ
1.# yum install dhcp 

หลังจากติดตั้ง DHCP เสร็จแล้ว เราก็ต้องมา config DHCP ให้ทำงานเข้ากัน Lan Card ใบที่ 2 ไฟล์ config ของ DHCPจะอยู่ที่ /etc/dhcp/dhcpd.conf สั่ง
2.#vi /etc/dhcp/dhcpd.conf  # เข้าไปแก้ไขไฟล์ config

ตัวอย่างไฟล์คอนฟิก /etc/dhcp/dhcpd.conf
# /etc/dhcp/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
3.[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  ]

ไม่มีความคิดเห็น:

แสดงความคิดเห็น