Skip to content

Latest commit

 

History

History
143 lines (135 loc) · 2.82 KB

ethernet to ap.md

File metadata and controls

143 lines (135 loc) · 2.82 KB

Raspberry pi-inbuilt wifi ap with internet connected on ehternet port.

For configuring the system I assume you have installed raspian os with desktop and enabled ssh and/or vnc. First update date and time:

date

Ouptput:

Sun 26 Jan 18:43:19 IST 2020

Set date and time accordingly:

sudo date -s "Sun 26 Jan 18:43:19 IST 2020"

Update and upgrade system:

sudo apt update && sudo apt full-upgrade -y 

Install dnsmasq and hostapd.

sudo apt install dnsmasq hostapd bridge-utils -y

Since the configuration files are not ready yet, turn the new software off as follows:

sudo systemctl stop dnsmasq
sudo systemctl stop hostapd

To configure the static IP address, edit the dhcpcd configuration file with:

sudo nano /etc/dhcpcd.conf

Go to the end of the file and add:

interface wlan0
static ip_address=192.168.0.10/24
nohook wpa_supplicant
denyinterfaces eth0
denyinterfaces wlan0

Save and exit.

Configuring the DHCP server (dnsmasq):

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo nano /etc/dnsmasq.conf

Add to the bottom of the file:

interface=wlan0
  dhcp-range=192.168.0.11,192.168.0.30,255.255.255.0,24h

Save and exit.

Configuring the access point host software (hostapd):

sudo nano /etc/hostapd/hostapd.conf

Add to the file. Change the ssid and wpa_passphrase of your choice

interface=wlan0
bridge=br0
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
ssid=NETWORK
wpa_passphrase=PASSWORD

Save and exit. We now need to tell the system where to find this configuration file.

sudo nano /etc/default/hostapd

Uncomment #DAEMON_CONF and add the following:

DAEMON_CONF="/etc/hostapd/hostapd.conf"

Save and exit.

Edit /etc/sysctl.conf

sudo nano /etc/sysctl.conf

Uncomment this line #net.ipv4.ip_forward=1

net.ipv4.ip_forward=1

Save and exit.

Add a new iptables rule:

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Save the new iptables rule:

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

Edit the file /etc/rc.local:

sudo nano /etc/rc.local 

Add just above exit 0:

iptables-restore < /etc/iptables.ipv4.nat

Save and exit.

Setup the bridge for internet connection:

sudo brctl addbr br0
sudo brctl addif br0 eth0

Edit the interfaces file:

sudo nano /etc/network/interfaces

Add the following lines at the end of the file:

auto br0
iface br0 inet manual
bridge_ports eth0 wlan0

Save and exit.

Now enable and start hostapd:

sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl start hostapd

Reboot:

sudo reboot now