How to install DHCP Service on CentOS 8



ဒီတစ်ခါမှာတော့ ကျနော်တို့ရဲ့ ရုံးတွေ သို့မဟုတ် ပရောဂျက်တွေမှာ DHCP serverကို Linux ပေါ်မှာ ဘယ်လို run ကြမလဲဆိုတဲ့အပိုင်းလေးကို share ပေးချင်ပါတယ်။ ပုံမှန်အားဖြင့်တော့ DHCP အတွက်ကတော့ TP link router, Dlink router လေးသုံးလိုက်မယ် သို့မဟုတ် Infra အတွက် သုံးကြမယ်ဆိုရင်တော့ MS server ထိုင်မလား ၊ Fortigate firewall တွေသုံးကြမလား၊ mikrotik သုံးမလား သို့မဟုတ် Linux သုံးမလားဆိုတာကို ကျနော်တို့တွေ စဉ်းစားပြီးတော့ ရွေးချယ်ကြပါတယ်။ Dynamic Host Configuration Protocol (DHCP)ကို အားလုံးလည်း သိပြီးဖြစ်တဲ့အတိုင်း IP Auto Assign အတွက်အပြင် static IP Auto assign အတွက်ပါ အသုံးပြုနေကြပါတယ်။ ဒီအထဲကမှာ Linux မှာ ဘယ်လို Configuration တွေ လုပ်လို့ရမလဲ ဆိုတာကို ကျနော်တို့ လက်တွေ့ စမ်းသပ်ကြည့်ကြရအောင်။


1. Install DHCP server on CentOS8:
[root@cent8 ~]# dnf -y install dhcp-server-12:4.3.6-34.el8.x86_64
Firstly you must change static IP in you NIC
2. Edit in network configuration file:
[root@cent8 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens160
3. change the following text:
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.0.100
PREFIX=24
GATEWAY=192.168.0.1
Press (:wq) for save and exit.
4. reload network card and service:
[root@cent8 ~]# nmcli connection up ens160
[root@cent8 ~]# nmcli connection reload
5. Open the main configuration file and define your DHCP server options:
[root@cent8 ~]# vim /etc/dhcp/dhcpd.conf
Start by setting the following global parameters which will apply to all the subnetworks (do specify values that apply to your scenario) at the top of the file:
option domain-name "local.com";
option domain-name-servers cent8.local.com;
default-lease-time 3600;
max-lease-time 7200;
authoritative;
6.  Now, define a subnetwork; in this example, we will configure DHCP for 192.168.0.0/24 LAN network (remember to use parameters that apply to your scenario):
subnet 192.168.0.0 netmask 255.255.255.0 {
        option routers  192.168.0.1;
        option subnet-mask      255.255.255.0;
        option domain-name-servers      192.168.0.100;
        range   192.168.0.150   192.168.0.200;
}
7.  Now start the DHCP service for the mean time and enable it to start automatically from the next system boot, using following commands:
[root@cent8 ~]# systemctl start dhcpd.service
[root@cent8 ~]# systemctl enable dhcpd.service
8.  Next, do not forget to permit DHCP service as below:
[root@cent8 ~]# firewall-cmd --add-service=dhcp –permanent
[root@cent8 ~]# firewall-cmd --reload
Configuring DHCP Clients  (windows)


#Openlearning
#SheinMyintAung




Comments