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

Leave a Reply

Your email address will not be published. Required fields are marked *