Tuesday 5 October 2010

Turning a PC into a Wireless Access Point pt II

So, I've got my design, setting up an Access Point should be easy - after all, I can remember when Linux was one of the few operating systems that supported wireless networking (back when you had to build your own hardware).

Actually it is not easy.  Firstly, finding the right documentation is a nightmare.

There's an awfully large quantity of out of date stuff leading to a lot of dead ends.

The steps (for Ubuntu server 10.04 on a box with 1 wireless card and 1 ethernet connection) should be:
  1. make sure your wireless card works
  2. install bridging (thanks ubuntulinuxhelp.com)


    sudo apt-get install bridge-utils
    enable the bridge by entering its details into the interfaces file - since there are two network interfaces in my computer and only one had been enabled up to this point, I simply moved the card's IP address details into the bridge section.


    sudo cp /etc/network/interfaces /etc/network/interfaces.ORIG
    sudo vi /etc/network/interfaces

    # The loopback network interface
    auto lo
    iface lo inet loopback

    # The primary network interface
    auto eth0

    #This is the Wireless section.
    auto wlan0
    iface wlan0 inet manual
    wireless-mode master
    wireless-essid MyNewSID

    #This is the Bridge section.
    auto br0
    iface br0 inet static
    address 192.168.1.251
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255
    gateway 192.168.1.253
    bridge-ports eth0 wlan0

    I'd recommend checking that the computer still boots properly at this stage - I messed up the networking by inadvertently getting the address wrong on my first attempt.
  3. install hostapd


    sudo apt-get install hostapd
    changes to /etc/hostapd/hostapd.conf (thanks Denilson) - all other entries left as default.

    driver=nl80211
    ssid=MyNewSID
    country_code=GB (thanks cisco)
    hw_mode=g
    channel=3
    max_num_sta=3

    macaddr_acl=1
    accept_mac_file=/etc/hostapd/hostapd.accept
    wep_default_key=0
    wep_key0=00000000ED57ERR0C500000000


    Then add the MAC addresses for the Games Adaptor and the Dreambox to /etc/hostapd/hostapd.accept in the format xx:xx:xx:xx:xx:xx

    The final piece in the jigsaw is getting hostapd to run as a daemon automatically on startup - edit the config file /etc/default/hostapd and uncomment RUN_DAEMON="YES" (thanks BadOpCode)
  4. restart networking and hostapd (or just reboot):


    sudo /etc/init.d/network-interface restart
    sudo /etc/init.d/hostapd start
So why doesn't it work ?
All looks fine from my laptop:

sudo iwlist scan
lo        Interface doesn't support scanning.

eth0      Interface doesn't support scanning.

eth1      Scan completed :
          Cell 04 - Address: 00:1B:11:06:AB:52
                    ESSID:"MyNewSID"
                    Protocol:IEEE 802.11bg
                    Mode:Master
                    Frequency:2.422 GHz (Channel 3)
                    Encryption key:on
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                              9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
                              48 Mb/s; 54 Mb/s
                    Quality=61/100  Signal level=-64 dBm
                    Extra: Last beacon: 188ms ago

And the details on the server look fine too:


sudo ifconfig
br0       Link encap:Ethernet  HWaddr 00:1b:11:06:ab:52
          inet addr:192.168.1.251  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::21b:11ff:fe06:ab52/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6537 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3635 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:4028355 (4.0 MB)  TX bytes:522361 (522.3 KB)

eth0      Link encap:Ethernet  HWaddr 00:50:8b:c6:ff:47
          inet6 addr: fe80::250:8bff:fec6:ff47/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6614 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3635 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4137117 (4.1 MB)  TX bytes:522361 (522.3 KB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:154 errors:0 dropped:0 overruns:0 frame:0
          TX packets:154 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:32425 (32.4 KB)  TX bytes:32425 (32.4 KB)

mon.wlan0 Link encap:UNSPEC  HWaddr 00-1B-11-06-AB-52-30-30-00-00-00-00-00-00-00-00
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 00:1b:11:06:ab:52
          inet6 addr: fe80::21b:11ff:fe06:ab52/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:498 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:145552 (145.5 KB)





sudo iwconfig
lo        no wireless extensions.

eth0      no wireless extensions.

wlan0     IEEE 802.11bg  Mode:Master  Frequency:2.422 GHz  Tx-Power=12 dBm
          Retry  long limit:7   RTS thr=2347 B   Fragment thr=2346 B
          Power Management:off
        
br0       no wireless extensions.

mon.wlan0  IEEE 802.11bg  Mode:Monitor  Frequency:2.422 GHz  Tx-Power=12 dBm
          Retry  long limit:7   RTS thr=2347 B   Fragment thr=2346 B
          Power Management:off

I've tried removing all protection, but still nothing will connect.

Let's see what is going on:


sudo brctl show
bridge name bridge id          STP enabled   interfaces
br0         8000.001b1106ab52     no         eth0
                                             wlan0

...so the bridge definitely exists.

What can the bridge see?

sudo brctl showmacs br0
port no     mac addr          is local?     ageing timer
  1     00:0d:4b:30:6e:94     no            30.28
  1     00:16:67:00:4a:d4     no             9.71
  1     00:16:6f:b2:41:d4     no             0.04
  2     00:1b:11:06:ab:52     yes            0.00
  1     00:50:8b:c6:ff:47     yes            0.00
  1     98:8b:5d:9d:c4:f8     no            45.70

...the bridge is only seeing stuff on the wired side (port 1).

TBC...

2 comments:

Anonymous said...

It agree, the helpful information

Anonymous said...

I appreciatе, cauѕе I found exactly what I waѕ hаving a look
foг. You have enԁed my 4 dаy lengthy hunt!
Gοԁ Вless you mаn.
Have a greаt ԁaу. Byе

my web blog Homepage des Autors besuchen
Also see my website - Buildpageranks.com