Have you ever got into situation where you need to access wireless without having WIFI AP / Router? If you are searching for solution to turn your Linux Box into wifi router, this article will guide you through.
I have tested this on Fedora 14 & Ubuntu 10.10, this should work with RHEL & CentOS also.
To configure Linux box as Wifi router all you need is
hostadp
dhcp server
ip forwarding
iptables masquerade for external interface i.e eth0
Ubuntu 10.10 Box as WIFI Router
apt-get install hostapd |
Save following contents as /etc/hostapd/hostapd.conf
# # This will give you a minimal, insecure wireless network. # # DO NOT BE SATISFIED WITH THAT!!! # # For more information, look here: # # http://wireless.kernel.org/en/users/Documentation/hostapd # ctrl_interface=/var/run/hostapd #ctrl_interface_group=wheel # Some usable default settings... macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 # Uncomment these for base WPA & WPA2 support with a pre-shared key #wpa=3 #wpa_key_mgmt=WPA-PSK #wpa_pairwise=TKIP #rsn_pairwise=CCMP # DO NOT FORGET TO SET A WPA PASSPHRASE!! #wpa_passphrase=YourPassPhrase # Most modern wireless drivers in the kernel need driver=nl80211 driver=nl80211 # Customize these for your local configuration... interface=wlan0 hw_mode=g channel=1 ssid=LinuxReaders macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=3 wpa_passphrase=linuxreaderscom wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP |
In above config you’ll need to change ssid & password (wpa_passphrase).
To start hostapd
hostapd -d /etc/hostapd/hostapd.conf |
Install & Configure DHCPD
Further config for wlan0
mentione wlan0 as interfaces in /etc/default/dhcp3-server |
Assign IP to wlan0
ifconfig wlan0 inet 192.168.9.1 netmask 255.255.255.0 |
Enter followings in /etc/rc.local to get wifi working on every reboot.
echo 1 > /proc/sys/net/ipv4/ip_forward /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE ifconfig wlan0 inet 192.168.9.1 netmask 255.255.255.0 hostapd -d /etc/hostapd/hostapd.conf & /etc/init.d/dhcp3-server restart |
Fedora Box as WIFI Router
yum install hostapd -y |
Enter followings in /etc/hostapd/hostapd.conf
# Customize these for your local configuration... interface=wlan0 hw_mode=g channel=6 ssid=LinuxReaders macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=3 wpa_passphrase=linuxreaderscom wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP |
chkconfig hostapd on service hostapd restart |
Install & Configure DHCPD (based on CentOS)
Further config for wlan0
make sure only wlan0 is configured in /etc/sysconfig/dhcpd
Assign IP to wlan0
ifconfig wlan0 address 192.168.9.1 netmask 255.255.255.0
Enter followings in /etc/rc.local
echo 1 > /proc/sys/net/ipv4/ip_forward /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE |
Once after running hostaspd you’ll find new wireless network
Read More about advance configuration
Pingback: Ubuntu Box as Wifi Router | TurboLinux Blog