How to install a wlan access point with dhcp server and ad blocker on your Raspberry Pi or Linux server.
sudo apt-get install hostapd isc-dhcp-server iptables-persistent dnsutils git iproute2 whiptail ca-certificatessudo nano /etc/dhcp/dhcpd.confchanges:
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;
authoritative;
subnet 192.168.42.0 netmask 255.255.255.0 {
range 192.168.42.10 192.168.42.50;
option broadcast-address 192.168.42.255;
option routers 192.168.42.1;
default-lease-time 600;
max-lease-time 7200;
option domain-name "local";
option domain-name-servers 192.168.42.1;
}sudo nano /etc/default/isc-dhcp-serverchanges:
INTERFACES="wlan0"nano /etc/network/interfaces.d/wlan0content:
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.42.1
netmask 255.255.255.0ifconfig wlan0 192.168.42.1sudo nano /etc/hostapd/hostapd.confcontent:
interface=wlan0 #<== CHANGE THIS
ssid=Raspberry
country_code=DE
hw_mode=g
channel=6 #<== CHANGE THIS
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=Raspberry #<== CHANGE THIS
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
wpa_group_rekey=86400
ieee80211n=1
wme_enabled=1sudo nano /etc/default/hostapdchanges:
DAEMON_CONF="/etc/hostapd/hostapd.conf"sudo nano /etc/sysctl.confchanges:
net.ipv4.ip_forward=1sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
sh -c "iptables-save > /etc/iptables/rules.v4"/usr/sbin/hostapd /etc/hostapd/hostapd.conf
strg+csystemctl unmask hostapd
systemctl enable hostapd
systemctl start hostapd
systemctl enable isc-dhcp-server
systemctl start isc-dhcp-servercurl -sSL https://install.pi-hole.net | bash- select eth0 device
- do not activate static ip settings
- wait
- http://pi-hole/admin/settings.php?tab=dns
- Permit all origins
- Never forward non-FQDN A and AAAA queries
- Use Conditional Forwarding -> your router ip subnet
- http://pi-hole/admin/groups-adlists.php
- http://pi-hole/admin/gravity.php
- update gravity lists