how to make wlan of a linux device work in AP mode with hostapd.(ubuntu20.04,nanopi-neo4)
Hello everyone,welcome to learning linux.In today’s video,I will show you how to make wlan of a linux device work in AP mode with hostapd.
Step1:
install hostapd:apt-get install hostapd
Step2:
modify /etc/hostapd/hostapd.conf
hw_mode=g
channel=11
#country_code=US
driver=nl80211
#driver=hostap
ssid=wifiap
interface=wlan0
# possible MAC address restriction
macaddr_acl=0
#accept_mac_file=/etc/hostapd.accept
#deny_mac_file=/etc/hostapd.deny
#ieee8021x=1 # Use 802.1X authentication
ieee80211n=1
#wmm_enable=1
auth_algs=1
ignore_broadcast_ssid=0
# encryption
wpa=2
wpa_passphrase=0123456789
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
#ctrl_interface=/var/run/hostapd
# Only root can configure hostapd
#ctrl_interface_group=0
Step3:
modify /etc/network/interfaces
auto wlan0
iface wlan0 inet static
address 10.0.0.1
netmask 255.255.255.0
gateway 10.0.0.1
Step4:
modify /etc/dnsmasq.conf
interface=wlan0
dhcp-range=10.0.0.2,10.0.0.105,255.255.255.0,12h
start ip,end if,net mask,lease time.
Step5:
We need to unmaks and enable hostapd service.
systemctl unmask hostapd.service
systemctl enable hostapd.service
step6:
we need to enable ip forward.
/etc/sysctl.conf
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1
Step7:
reboot system
Step8:
apt-get install iptables
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
After this,devices connected to the AP have the internet connections now.
ipv4