Set up a hotspot with Linux
From Linuxintro
Revision as of 15:32, 8 July 2012 by imported>ThorstenStaerk
This is an example how to turn your computer into an accesspoint for wireless networks. My typical usecase for this is that I am in a place where I have to set up an UMTS connection to the internet and I want to share this internet connection as WLAN with others.
Contents
SUSE Linux 12.1
This guide is based on SUSE Linux 12.1 but should work same or similar for every distribution. We will use the software HostAPD for this.
what you need
- a Linux distribution with a kernel greater than about 2.6.30, in this example we use SUSE Linux 12.1
- a USB wireless adapter, in this example we use a Conceptronic device with a RaLink chipset
what you do
create connectivity
- plug in your USB wireless network adapter
- find out how to activate the driver:
linux-noqb:~ # hwinfo --usb [...] 22: USB 00.0: 0000 Unclassified device [Created at usb.122] Unique ID: doL0.gHs6xlT8BAF Parent ID: FKGF.0j9+vWlqL56 SysFS ID: /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6:1.0 SysFS BusID: 2-1.6:1.0 Hardware Class: unknown Model: "Ralink 802.11 bg WLAN" Hotplug: USB Vendor: usb 0x14b2 "Ralink" Device: usb 0x3c22 "802.11 bg WLAN" Revision: "0.01" Driver: "rt73usb" Driver Modules: "rt73usb" Device File: wlan0 Speed: 480 Mbps HW Address: 00:80:5a:4e:1a:eb Link detected: yes Module Alias: "usb:v14B2p3C22d0001dc00dsc00dp00icFFiscFFipFF" Driver Info #0: Driver Status: rt73usb is active Driver Activation Cmd: "modprobe rt73usb" Config Status: cfg=new, avail=yes, need=no, active=unknown Attached to: #12 (Hub)
- Activate the driver
modprobe rt73usb
- Activate the NIC
ifup wlan0
- Install HostAPD
yast -i HostAPD
- Do the following settings in /etc/hostapd.conf
driver=nl80211 bridge=br0 channel=3 hw_mode=g auth_algs=1
- Note
- channel=3 and hw_mode=g will work on almost all modern wireless USB adapters, however it may be possible to find one that does not work.
- Start hostapd
hostapd /etc/hostapd.conf
- verify that you see a wireless LAN with the ESSID test, e.g. on your mobile phone
- create a network bridge on your computer
- assign an IP address to your bridge br0 like this:
brctl addif br0 wlan0 ifconfig br0 192.168.0.5
- set up a dhcp server listening on your network bridge br0. As name server, use 8.8.8.8 which is google's name server in the internet
- verify you can connect to the LAN test and get an IP address
Set up NAT
Set up NAT like this:
# echo 1 > /proc/sys/net/ipv4/ip_forward # iptables -t nat -A POSTROUTING -o <html>ppp0</html> -j MASQUERADE # iptables -A FORWARD -i <html>br0</html> -j ACCEPT # iptables -A FORWARD -i <html>wlan0</html> -j ACCEPT
Knoppix 7.02
sudo apt-get install hostapd zcat /usr/share/doc/hostapd/examples/hostapd.conf.gz >/etc/hostapd.conf
Now edit the lines in /etc/hostapd.conf:
driver=nl80211 channel=3 hw_mode=g auth_algs=1