I want to be able to connect multiple pis to one main Pi and have it share its Internet connection to them and provide static IPs. Currently I have a wireless adapter connected to the Internet on the main PI and im trying to use dnsmasq and hostapd to create an access point for other Pis to connect to and get Internet from the main Pi. Not a single tutorial has worked for me including the access point tutorial on the official website... not sure if its stretch or if i'm doing something wrong. The steps im following right now are below.
sudo apt-get update
sudo apt-get upgrade
sudo rpi-update
sudo apt-get install -y hostapd
sudo apt-get install -y dnsmasq
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf--->>>
network={
ssid="networkname"
psk="networkpassword"
}
--------------------------------
sudo reboot -h now
sudo systemctl stop dnsmasq
sudo systemctl stop hostapd
sudo nano /etc/dhcpcd.conf--->>>
interface wlan0
static ip_address=192.168.220.1/24
--------------------------------
sudo service dhcpcd restart
sudo nano /etc/hostapd/hostapd.conf--->>>
interface=wlan0
driver=nl80211
hw_mode=g
channel=6
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
macaddr_acl=0
ignore_broadcast_ssid=0
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
ssid=Pi3-network
wpa_passphrase=raspberry
--------------------------------
sudo nano /etc/default/hostapd--->>>
#DAEMON_CONF="" --->>> DAEMON_CONF="/etc/hostapd/hostapd.conf"
--------------------------------
sudo nano /etc/init.d/hostapd--->>>
DAEMON_CONF= --->>> DAEMON_CONF=/etc/hostapd/hostapd.conf
--------------------------------
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo nano /etc/dnsmasq.conf--->>>
interface=wlan0 # Use interface wlan0
listen-address=192.168.220.1 # Specify the address to listen on
bind-interfaces # Bind to the interface
server=8.8.8.8 # Use Google DNS
domain-needed # Don't forward short names
bogus-priv # Drop the non-routed address spaces.
dhcp-range=192.168.220.50,192.168.220.150,12h # IP range and lease time
--------------------------------
sudo sed -i '28 s/#//' sysctl.conf
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
BUILT IN WIFI TO DONGLE------------------------------------------
sudo iptables -F
sudo iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE
sudo iptables -A FORWARD -i wlan1 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o wlan1 -j ACCEPT
-----------------------------------------------------------------
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
sudo sed -i '20i\iptables-restore < /etc/iptables.ipv4.nat\' rc.local
sudo systemctl start hostapd
sudo systemctl start dnsmasq
sudo reboot -h now