# DHCP Server & Linux Hotspot

* <https://luemmelsec.github.io/I-got-99-problems-but-my-NAC-aint-one/>
* <https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/install-software>

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:

{% code title="/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;
}
```

{% endcode %}

Configure hotspot:

{% code title="/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
```

{% endcode %}

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

{% code title="/etc/network/interfaces" %}

```
iface wlan0 inet static
  address 192.168.200.1
  netmask 255.255.255.0
```

{% endcode %}

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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ppn.snovvcra.sh/admin/networking/dhcp-hostapd.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
