Difference between revisions of "Set up a hotspot with Linux"
From Linuxintro
imported>ThorstenStaerk |
imported>ThorstenStaerk |
||
Line 1: | Line 1: | ||
− | 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]]. | + | 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. |
− | + | 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 = | = 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 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 | * a USB wireless adapter, in this example we use a Conceptronic device with a RaLink chipset | ||
Line 30: | Line 29: | ||
Driver: "rt73usb" | Driver: "rt73usb" | ||
Driver Modules: "rt73usb" | Driver Modules: "rt73usb" | ||
− | Device File: | + | '''Device File: ''wlan0''''' |
Speed: 480 Mbps | Speed: 480 Mbps | ||
HW Address: 00:80:5a:4e:1a:eb | HW Address: 00:80:5a:4e:1a:eb | ||
Line 62: | Line 61: | ||
* verify that you see a wireless LAN with the ESSID '''test''', e.g. on your mobile phone | * 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: | * assign an IP address to your bridge br0 like this: |
Revision as of 05:40, 4 July 2012
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.
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