Homework Router Setup Guide  Oliver Sharma ([email protected])  Created: 12th February 2009  Last updated: 25th February 2009     

This  guide  presents  step‐by‐step  instructions  required  to  setup  and  install  an  Eee  PC  1000H  as  a  wired/wireless  router. 

 

Table of Contents   

1. Hardware.................................................................................................................................. 2  2. Software .................................................................................................................................... 2  3. Hardware installation .......................................................................................................... 2  3.1 Upgrade memory ............................................................................................................................. 2  3.2 Replace wifi card .............................................................................................................................. 2  3.3 Architecture........................................................................................................................................ 2  4. Installing Linux....................................................................................................................... 3  4.1 Preparing the installation disk................................................................................................... 3  4.2 Booting the Eee PC from the USB.............................................................................................. 3  4.3 Ubuntu installation.......................................................................................................................... 3  5. Connecting to the Internet.................................................................................................. 3  6. Installing required packages ............................................................................................. 4  7. Configuring the network ..................................................................................................... 5  8. Configuring the DHCP server ............................................................................................. 5  9. Configuring the access point daemon ............................................................................. 5  10. Setting up Network Address Translation (NAT)....................................................... 6  11. Setting up a Bluetooth Personal Area Network (PAN) ........................................... 6  11.1 Installing blueman ........................................................................................................................ 6  11.2 Configuring blueman ................................................................................................................... 7  11.3 Pairing ................................................................................................................................................ 7  11.4 Discoverable .................................................................................................................................... 7  12. Reboot ..................................................................................................................................... 7  13. Security................................................................................................................................... 8  14. Troubleshooting .................................................................................................................. 8  14. 1 No DNS? ............................................................................................................................................ 8  14.2 Can send but not receive packets........................................................................................... 8  14.3 No wireless device after software update .......................................................................... 8  14.4 Unable to have multiple VPN connection to same VPN server.................................. 8  14.5 No eth0 and eth1 ........................................................................................................................... 8  14.6 Some useful commands .............................................................................................................. 8 

   

 



1. Hardware  • •

 

• • • •

ASUS Eee PC 1000H‐BLK019L Netbook, Linux Preloaded, 1GB RAM,  160GB HDD (Black)  GIGABYTE GN‐WS50G  802.11 b/g Atheros AR5007 chipset mini‐PCI  express card  Max Value USB 2.0 10/100 Ethernet Adapter (MV42250)  Kingston 2GB 667MHz DDR2 Non‐ECC CL5 SODIMM  Fast Ethernet Switch  USB Pen Drive min. 1GB (only needed for installation) 

2. Software 

 

• • • • •

Ubuntu Linux  8.10 (kernel: 2.6.27‐11‐generic)  Madwifi‐HAL‐0.10.5.6  HostAPd 0.5.10  Dnsmasq 2.45  Blueman 1.01 

3. Hardware installation  3.1 Upgrade memory  The Eee PC comes with a 1GB RAM stick installed, which can be replaced with a  2GB stick:  1. Unplug power supply and remove battery  2. Unscrew and remove bottom cover of Eee PC (only the 2 screws next to  the battery slot)  3. Remove RAM stick by pulling apart the leavers holding it in from the sides  4. Replace with 2GB stick (ensure it clicks in)    3.2 Replace wifi card  Unfortunately the 802.11n card that ships with the Eee PC does not (yet) support  access point mode in Linux. The replacement card is an older 802.11g card with a  well‐supported chipset (Note: this is actually the same card/chipset that shipped  with older Eee PC models).  1. Unplug the black and white cables by pulling them straight up  2. Unscrew the 2 screws holding the card in place (this will make the card  pop up)  3. Swap wifi cards, screw back in, and plug in black (left) and white (right)  cable. (Note: the small screws are quite fiddly, so it helps to put them into  the card before pushing it down).    3.3 Architecture  The diagram below shows the network architecture. Note that the USB‐Ethernet  dongle is used for the uplink and that the Ethernet switch is plugged into the  LAN port. If you do not have a cable modem for testing, it can be plugged directly  into any network that provides a DHCP service.   

 



Wifi

Ethernet Switch

Eee PC

Internet USB Ethernet Dongle

Cable Modem

 

 

4. Installing Linux 

The pre‐installed Xandros Linux is replaced with a full Ubuntu Linux installation  as follows:  4.1 Preparing the installation disk  Since the Eee PC does not have a CD‐ROM drive, Linux is installed using the USB  pen drive. This pen drive is created using a second machine booted from the  Ubuntu live disk:  1. Download Ubutnu 8.10 from  http://www.ubuntu.com/getubuntu/download  2. Burn this ISO file to CD  3. Boot the machine from this CD (choose: try Ubuntu without installation)  4. Once logged in, select System­>Administration­>Create USB startup disk  5. Select the same ISO file used to create the live disk as the source image  6. Insert the USB pen drive and select it as the destination disk  7. Maximize the reserved extra space slider  8. Click Make Startup Disk    4.2 Booting the Eee PC from the USB  Insert the pen drive startup disk into the Eee PC. Press the power button and  immediately hold down the ESC key. Select the flash drive when prompted.    4.3 Ubuntu installation  The Ubuntu installation is straightforward – simply click through the install  wizard. Note that the entire hard disk can be used without needing to resize (this  will overwrite Xandros).   

5. Connecting to the Internet 

Note: all commands assume user root (either prepend sudo to all commands or  login as root using sudo -s)     



If everything is connected as shown in the architecture diagram above, you  should automatically be connected to the Internet via the USB‐Ethernet dongle  (device eth1). You can check that it has been assigned an IP address with  ifconfig.    Note that you may need to register the USB‐Ethernet dongle’s MAC address with  your service provider (e.g. your department’s tech support) before being able to  obtain an IP address via DHCP. The MAC address is also found with ifconfig.  Type dhclient eth1 to rerun the DHCP request.    You may also need to set an http proxy. Do this by adding the following line to  /etc/profile and then source it:   export http_proxy=http://wwwcache.whatever.ac.uk:8080/

 

6. Installing required packages 

The Ubuntu package manager (apt‐get) is used to install some required software  packages:  apt-get update apt-get build-dep hostapd apt-get install hostapd apt-get install madwifi-tools apt-get install bridge-utils apt-get install dnsmasq apt-get install ssh apt-get install linux-headers-$(uname –r)

  Next, download the madwifi and hostapd source code:  wget http://snapshots.madwifi-project.org/madwifi-hal-0.10.5.6current.tar.gz apt-get source hostapd

  Now compile and install the wifi drivers:  tar xvfz madwifi-hal-0.10.5.6-current.tar.gz cd madwifi-hal-0.10.5.6-r3942-20090205 make make install

  And then compile and install hostapd  cd .. tar xvfz hostapd_0.5.10.orig.tar.gz cd hostapd-0.5.10 vim defconfig

   

 

   

Uncomment CONFIG_DRIVER_MADWIFI=y  And set CFLAGS += -I../madwifi-hal-0.10.5.6-r3942-20090205 



cp defconfig .config make cp hostapd /usr/sbin cp hostapd_cli /usr/bin cp hostapd.conf /etc/hostapd

  Important: uninstall the Ubuntu network‐manager, as it causes problems with  the madwifi drivers when in access point mode:  apt-get remove network-manager

This will take down your network connection. To reconnect type:  ifconfig eth1 up dhclient eth1

 

7. Configuring the network  To load the wifi drivers at startup, add the following line to /etc/modules:    ath_pci autocreate=ap And add the following to /etc/modprobe.d/madwifi:    options ath_pci autocreate=ap   To add a virtual device that bridges the LAN and WLAN, add the following to  /etc/network/interfaces:    auto lo iface lo inet loopback auto eth1 iface eth1 inet dhcp auto eth0 iface eth0 inet manual auto ath0 iface ath0 inet manual auto br0 iface br0 inet static address 192.168.0.1 network 192.168.0.0 netmask 255.255.255.0 broadcast 192.168.0.255 bridge-ports eth0 ath0

 

8. Configuring the DHCP server  Set the following in /etc/dnsmasq.conf:    except-interface=eth1 dhcp-range=192.168.0.50,192.168.0.150,12h dhcp-authoritative log-dhcp

 

9. Configuring the access point daemon  Make the following changes in /etc/hostapd/hostapd.conf:    interface=ath0  



bridge=br0 driver=madwifi debug=1 hw_mode=g channel=6 wme_enabled=0 ssid=homenet wpa=3 wpa_psk_file=/etc/hostapd/hostapd.wpa_psk wpa_key_mgmt=WPA-PSK wpa_pairwise=CCMP

  Now create the WPA key file /etc/hostapd/hostapd.wpa_psk with the following  content:    00:00:00:00:00:00 whatever   Finally, make the following changes in /etc/default/hostapd:  Uncomment RUN_DAEMON=”yes” And set DAEMON_OPTS=”-dddd”  

10. Setting up Network Address Translation (NAT)  Add the following to /etc/rc.local (above exit 0):    echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE iptables -A FORWARD -i eth1 -o br0 -j ACCEPT iptables -A FORWARD -i br0 -o eth1 -j ACCEPT

11. Setting up a Bluetooth Personal Area Network (PAN)  The following steps guide you through the installation of blueman 1.01, used to  configure a Bluetooth Personal Area Network.  11.1 Installing blueman  Append the following lines to /etc/apt/sources.list:    deb http://ppa.launchpad.net/blueman/ppa/ubuntu

intrepid main

deb-src http://ppa.launchpad.net/blueman/ppa/ubuntu intrepid main

  Launchpad requires that you install their latest PPA key before granting access  to their Ubuntu packages. Copy the following public key into a new text file (e.g.  blueman.pub):    -----BEGIN PGP PUBLIC KEY BLOCK----Version: SKS 1.0.10 mI0ESXdhSgEEANHQYiA3beVTW6fb+CoRTyGwBybdgRetQ7/Pi6pSC44Gfd0J1z52sMYkm2MF wg94pt/gRsx8UaCySoIiBp5FNFcOP5+wZQsQJcKSDQFG7QPJ2izkoUOhZSCHLOkefiru0DKt maJ+VAhIKU0vEP80sou9mtnhGNumbMtzEMxezUbjABEBAAG0KkxhdW5jaHBhZCBQUEEgZm9y IEJsdWVtYW4gRGV2ZWxvcG1lbnQgVGVhbYi2BBMBAgAgBQJJd2FKAhsDBgsJCAcDAgQVAggD BBYCAwECHgECF4AACgkQaxWrkZUdweLSPAP+JbBBMqFge3a/ob3c8t2bLWkhs/5czJ1p5PPI 8lZeyjYF5N7FiuqtiS6joxk1z/w84lYU48JEQRvXTaI1VOQhjV5dHsuFCK4/9hKGWnb3JYDz XEds+4UrSetPZ6lsXW1sEEwQNI8Jo5u1BaOqn3WgM936pZve48bXXHgsN0OaSl8= =zUgC -----END PGP PUBLIC KEY BLOCK-----

  Or alternatively, obtain the key directly from their website:  https://launchpad.net/~blueman/+archive/ppa   

 



To import the key, you can use the Software Sources program under in the  system menu (System ­> Administration ­> Software Sources). Under the  Authentication tab, click on Import Key File and select the recently created  blueman.pub file), then close to apply changes.    Install blueman by running:    apt-get update apt-get install blueman

11.2 Configuring blueman  To configure blueman you must first disable the default Bluetooth Manager. To  do this, untick Bluetooth Manager in the Sessions Preferences menu (System ­>  Preferences ­> Sessions).    Next, start    blueman-applet then  blueman-services

  This will open Local Services: click on Network and enable Network Access Point  (NAP) then set the Bluetooth device’s static IP address (e.g. 192.168.3.1) and tick  Enable Routing (NAT). Finally, select “Let Blueman handle the network interfaces“  and click Apply.    Note: you may be prompted with the error message “Failed to bind DHCP server  socket”, which indicates that dnsmasq is already running and can be safely  ignored.  11.3 Pairing  To pair with a Bluetooth device:  1. Double click the Bluetooth icon located on the gnome menu bar (top right  of screen, next to clock)  2. Click search to discover active Bluetooth devices  3. Right‐click the item to pair with and select “trust”  4. Right‐click the item again and select “bond”  5. Enter the pin code (e.g. 1234) that the device should be prompted with  6. Enter the same pin code on the Bluetooth device when prompted  11.4 Discoverable  To make the router discoverable for other Bluetooth devices: right‐click the  Bluetooth icon (top right of screen, next to clock), select Adapters and then set  the visibility to “always visible”. 

12. Reboot 

After rebooting your system, a wifi network called homenet with WPA password  whatever will be advertised. Connect to it and you will receive an IP address via  DHCP. You should now be able to browse the web.   

 



13. Security 

Apart from WPA2 for authenticating the wifi connections, this is an insecure  setup. The firewall is configured to allow all incoming and outgoing traffic. Also,  there is no MAC address restriction setup yet.  

14. Troubleshooting  14. 1 No DNS?  The DNS server addresses are obtained by dnsmasq from /etc/resolv.conf. This  file should be created automatically by running dhcpclient on eth1 (the uplink).  14.2 Can send but not receive packets  Ensure that you have uninstalled network‐manager, which conflicts with the  madwifi drivers.  14.3 No wireless device after software update  The Ubuntu package manager (apt‐get) may have overwritten your custom  compiled madwifi drivers. Rerun make install in your madwifi‐hal directory.  14.4 Unable to have multiple VPN connection to same VPN server  Load the ip_nat_pptp kernel module, which adds support for network address  translation of PPTP connections as used by Microsofts VPN server. Append  ip_nat_pptp to /etc/modules to load this module on startup.  14.5 No eth0 and eth1  Your system may have renamed these devices to eth2 and eth3 respectively.  Use dmesg | grep eth0 to verify and adjust all of the above configuration files  accordingly.  14.6 Can’t get IP address via DHCP over bluetooth  Depending on the static IP address that you assigned to your Bluetooth device on  the router, you may have to add an additional dhcp‐range to your  /etc/dnsmasq.conf file. E.g. If your Bluetooth device’s IP address is 192.168.2.1,  you may need to add “dhcp‐range=192.168.2.50,192.168.2.150,12h” and restart  dnsmasq.  14.6 Some useful commands  Display all LAN/WLAN traffic: tcpdump -i br0 Debug wifi drivers: athdebug and 80211debug then dmesg Check that wifi card is in access point mode: iwconfig Display network devices: ifconfig Monitor system logs: tail -f /var/log/syslog