DHCP Server & Linux Hotspot

Install stuff:

sudo apt install isc-dhcp-server hostapd -y
sudo systemctl enable isc-dhcp-server
sudo systemctl unmask hostapd
sudo systemctl enable hostapd

Configure DHCP:

/etc/dhcp/dhcpd.conf
option domain-name "local";
option domain-name-servers 8.8.8.8, 8.8.4.4;
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.200.0 netmask 255.255.255.0 {
  range 192.168.200.2 192.168.200.20;
  option subnet-mask 255.255.255.0;
  option broadcast-address 192.168.200.255;
}

Configure hotspot:

/etc/hostapd/hostapd.conf
interface=wlan0
driver=nl80211
ssid=LinuxHotspot
hw_mode=g
channel=11
macaddr_acl=0
ignore_broadcast_ssid=0
auth_algs=1
wpa=2
wpa_passphrase=Passw0rd!
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
wpa_group_rekey=86400
ieee80211n=1
wme_enabled=1

Configure interface (+ set the iface name in /etc/default/isc-dhcp-server):

/etc/network/interfaces
iface wlan0 inet static
  address 192.168.200.1
  netmask 255.255.255.0

Set static IP on the interface:

sudo ifconfig wlan0 down
sudo ifconfig wlan0 192.168.200.1
sudo ifconfig wlan0 up

Restart the services:

$ sudo service isc-dhcp-server restart
$ sudo service hostapd restart

Last updated