This article will describe running DHCP server.
Table of Contents
1 Install isc-dhcp-server
Install isc-dhcp-server with apt.
$ sudo apt install -y isc-dhcp-server
2 /etc/dhcp/dhcpd.conf
Define domain name, DHCP server IP address and gateway IP address. Mapping MAC address 52:54:00:e9:ee:38 to IP address 192.168.11.128.
$ cat /etc/dhcp/dhcpd.conf subnet 192.168.11.0 netmask 255.255.255.0 { option domain-name "my.net"; option domain-name-servers 192.168.11.2, 192.168.11.1; option routers 192.168.11.1; } host debian-8 { hardware ethernet 52:54:00:e9:ee:38; fixed-address 192.168.11.128; }
3 Run isc-dhcp-server
Run isc-dhpc-server with systemd.
$ sudo systemctl enable isc-dhcp-server $ sudo systemctl restart isc-dhcp-server
4 Execution result
Checking IP address on MAC address 52:54:00:e9:ee:38 machine.
$ /sbin/ifconfig eth0 Link encap:Ethernet HWaddr 52:54:00:e9:ee:38 inet addr:192.168.11.128 Bcast:192.168.11.255 Mask:255.255.255.0 inet6 addr: fe80::5054:ff:fee9:ee38/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:311 errors:0 dropped:0 overruns:0 frame:0 TX packets:187 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:41640 (40.6 KiB) TX bytes:26614 (25.9 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) $ cat /etc/resolv.conf # Generated by NetworkManager search my.net nameserver 192.168.11.2 nameserver 192.168.11.1
Ubuntu 16.04 needs edit to edit NetworkManager.conf for generating /etc/resolv.conf with DHCP server infomation.
$ sudo diff -uprN /etc/NetworkManager/NetworkManager.conf{.org,} --- /etc/NetworkManager/NetworkManager.conf.org 2016-04-28 01:07:32.015679999 +0900 +++ /etc/NetworkManager/NetworkManager.conf 2016-04-28 01:07:45.307679999 +0900 @@ -1,6 +1,6 @@ [main] plugins=ifupdown,keyfile,ofono -dns=dnsmasq +#dns=dnsmasq [ifupdown] managed=false $ sudo systemctl restart network-manager