Ubuntu : Setting Wifi HotSpot using HostAPd

57 sec read

Setting Wifi HotSpot using HostAPd

Checking Wifi

:: Check Wifi AP Support

sudo aptitude install iw
iw list

make sure you see “AP” in Support interface:

	Supported interface modes:
		 * IBSS
		 * managed
		 * AP
		 * AP/VLAN
		 * WDS
		 * monitor
		 * mesh point
		 * P2P-client
		 * P2P-GO

 

Install HostAPd

:: Installing HostAPd to provide hostspot via Wifi

sudo aptitude install hostapd

:: Setting Hotspot in HostAPd

sudo vi /etc/hostapd/hostapd.conf

Add the configuration like these:

interface=wlan0
ssid=your_ssid_name
hw_mode=g
channel=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=your_ssid_password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

:: Setting HostAPd in daemon

sudo vi /etc/default/hostapd

add or changed in this line:

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

:: Starting HostAPd

sudo /etc/init.d/hostapd restart

 

Setup DHCP Server

:: Installing ISC DHCP server

sudo apt-get install isc-dhcp-server

:: Setting ISC DHCP Server

sudo vi /etc/dhcp/dhcpd.conf

commented in these lines:

# option definitions common to all supported networks...
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;

#default-lease-time 600;
#max-lease-time 7200;

and add or append dhcp ip like these:

subnet 10.10.0.0 netmask 255.255.255.0 {
        range 10.10.0.2 10.10.0.16;
        option domain-name-servers 8.8.8.8, 8.8.4.4;
        option routers 10.10.0.1;
}

:: Starting ISC DHCP Server

sudo /etc/init.d/isc-dhcp-server restart

 

Set Wifi IP and Firewall

:: Setup IP for Wifi device

sudo ifconfig wlan0 10.10.0.1 netmask 255.255.255.0 up

:: Setting POSTROUTING in iptables

sudo iptables -t nat -A POSTROUTING -s 10.10.0.0/16 -o eth0 -j MASQUERADE

change eth0 with your active internet connection, like ppp0 for usb modem connection.

Reference

:: Links
+ Google
+ Dashohoxha

How to install NextCloud in Ubuntu 22.04

What’s NextCloud Nextcloud is an open-source software suite that offers a secure, self-hosted alternative to popular cloud storage and productivity platforms. With a focus...
sysadmin.id
8 min read

Reset root password on CentOS 7

Edit boot menu on-the-go 0. reboot the CentOS 7 and press ESC when GRUB menu show up on the screen and press “e” 1....
sysadmin.id
18 sec read

Free ext4 reserved blocks with tune2fs

Check disk usage df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 95G 82G 7.9G 92% / Check size of Reserved block count...
sysadmin.id
19 sec read