loading
I am currently looking for someone to help out with this blog. I didn't realize the scope that this blog would effect. Hits from countries in political strife and the like, people looking for a way to communicate outside of government control. If you would like to help please send me an email George dot Endrulat at Gmail dot Com.

Wednesday, June 1, 2011

How to Setup a Wireless Ubuntu Router | Ubuntu Linux Help

How to Setup a Wireless Ubuntu Router | Ubuntu Linux Help






Router brokeThis morning I was moving some stuff around and my router fell, smashing to pieces. Oh no! I need a wireless connection today. The router was a noisy (the fan drives you crazy), older (but faithful) boat anchor. I was in a pinch, with no time to buy a new one (it's a long drive). So, I thought a quicker (and for me "fun"), fix would be to set up a temporary router on an old PC.
Here's how to do that; I hope this helps others and gives hobbyists a fun project.
Here's the hardware used:
Celeron based PC (755MHz)
512MB RAM
10GB ATA HDD
Realtek 10/100 NIC (2 of them)
There is an integrated NIC on the motherboard, but I couldn't find any drivers that worked.
AtlantisLand I-Fly A02WP54G (which I borrowed from another PC).
A Basic Server Install:
First thing you'll need to complete is a base server install on the PC (don't use LAMP or DNS). From googling, I found out that the wireless card I'm using will work from Ubuntu versions 5.10 (Breezy) and newer.
After the installation of the server is complete, make sure that you configure your repositories to use "Universe".
Edit this file: /etc/apt/sources.list
sudo nano -w /etc/apt/sources.list
And add this: universe
The lines you edit, will look something like this:
deb http://ca.archive.ubuntu.com/ubuntu/ edgy main restricted
deb-src http://ca.archive.ubuntu.com/ubuntu/ edgy main restricted
Make sure you create a backup copy of this file BEFORE you do anything. I should also note that when examining your sources.list, if you see an entry for CD,remove it. (For people interested in enhancing their repositories, please see here: http://ubuntulinuxhelp.com/the-best-ubuntu-linux-repository-list/)
After editing the sources.list file, use this command to update, so that you will receive the most recent versions of updates as we complete the installation:
sudo apt-get update
The Network:
This PC needs to work like the broken router did. Therefore:
eth0 = (Which is on the motherboard) is not working, and I think it's a driver related issue.
eth1 = The external WAN connection to my ISP.
eth2 = Is the internal LAN connection to the network.
ath0 = Wireless connection.
br0 = The virtual bridge connecting eth2 (LAN) to ath0 (Wireless) - So that wireless connections can communicate on the network, which in turn can communicate with the Internet.
Adding the bridge is not too difficult. First we need to get the package like this:
sudo apt-get install bridge-utils
Now edit the network configuration file (interfaces) with this command (you don't have to use nano, you can use any text based editor):
sudo nano /etc/network/interfaces
Edit the open file like this:
(I have included notes in this code below, please make sure that you check them).
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
#The loopback network interface
auto lo
iface lo inet loopback
#etho is on the motherboard and the driver is not available? So... I had to disable this section.
#auto eth0
#iface eth0 inet dhcp
#pre-up iptables-restore < /etc/iptables.conf
#This is the WAN section. It connects to the Internet.
#Normally this uses DHCP from your ISP, so leave it as DHCP if your ISP uses DHCP.
#The "pre-up" command loads up the firewall iptables. Leave it enabled.
auto eth1
iface eth1 inet dhcp
pre-up iptables-restore < /etc/iptables.conf
#This is the Wireless section.
auto ath0
iface ath0 inet manual
wireless-mode master
#You must enter your own ESSID below - Change the word "nomadic" to your own ESSID.
wireless-essid nomadic
#This is the Bridge section. You don't have to use the 10.1.1.0, which is a proper private IP (LAN) network range, you can change it to your needs.
auto br0
iface br0 inet static
address 10.1.1.1
network 10.1.1.0
netmask 255.255.255.0
broadcast 10.1.1.255
bridge-ports eth2 ath0
Save the file and exit.
With regards to the "eth1" section, if your ISP does not use DHCP, then they can provide you with the correct information. That section should then be configured to look like this:
auto eth1
iface eth1 inet static
address 72.138.51.135
netmask 255.255.254.0
gateway 72.138.50.1
pre-up iptables-restore < /etc/iptables.conf
Note: DNS settings for the LAN (to be able to access web sites), is covered further down in the DHCP section.
Get WiFi Working:
The network card uses a madwifi driver and you can check here to see how to detect and install it: https://help.ubuntu.com/community/Router/Madwifi
I should point out that this resource helps to tell if your WiFi card is compatible:https://help.ubuntu.com/community/WifiDocs/WirelessCardsSupported but I don't think it is an exclusive list. You can also try here:http://ubuntulinuxhelp.com/ubuntu-hardware-compatability-list-hcl/
We need WAP in Master mode, from one of the help.Ubuntu.com links (above):
"If you are plan on using this wireless network adapter in "master" mode (i. e. for the purposes of setting up a wireless router)..."
So, let's do this to install the madwifi drivers:
wget http://umn.dl.sourceforge.net/sourceforge/madwifi/madwifi-0.9.3.1.tar.gz
tar -xvzf madwifi-0.9.3.1.tar.gz
cd madwifi-0.9.3.1
And this to install the tools + compile and install the needed module:
Just as the link said, we need to switch to master mode. We do this by creating the required file:
sudo nano /etc/modprobe.d/madwifi
And adding this code to the madwifi file:
options ath_pci autocreate=ap
Our wireless card is now in Master mode and we just have to load it by doing this:
sudo modprobe ath_pci
Time to move on...
The Firewall Needs to Forward Data:
We are setting up this firewall to simply forward data, not to protect the network! (Network protection is a whole other topic).
As with the WiFi section above, Ubuntu also has a great resource for that here:https://help.ubuntu.com/6.10/ubuntu/serverguide/C/firewall-configuration.html
And again, I am able to use their help in this guide.
Remember that eth0 is the WAN (Gateway) connection to the Internet, so (using the Ubuntu information), we need to do this:
sudo iptables -t nat -A POSTROUTING -s 10.1.1.0/24 -o eth1 -j MASQUERADE
sudo iptables -A FORWARD -s 10.1.1.0/24 -o eth1 -j ACCEPT
sudo iptables -A FORWARD -d 10.1.1.0/24 -m state --state ESTABLISHED,RELATED -i eth1 -j ACCEPT
Logging is a good idea. Logs should be found here:
/var/log/messages
/var/log/syslog
/var/log/kern.log.
And to enable the logging, use this code:
sudo iptables -A INPUT -m state --state NEW -p tcp --dport 80 -j LOG --log-prefix "NEW_HTTP_CONN: "
Remember when we entered this line "pre-up iptables-restore < /etc/iptables.conf" into the network setup? Let's make sure we save the file accordingly (so that this works):
sudo iptables-save > /etc/iptables.conf
We need the router to be able to forward data (packets) using IPv4 (which most everyone uses). You can edit this file:
sudo nano /etc/sysctl.conf
To change this line:
#net.ipv4.conf.default.forwarding=1
So that it looks like this:
net.ipv4.conf.forwarding=1
DHCP needs to run so PC's can connect easily.
Install DHCP:
sudo apt-get install dhcpd
Edit the configuration file for DHCP:
sudo nano /etc/dhcpd.conf
To look like this (your LAN based IP network address might be different, just make sure it matches what you set up in the "Network" section above):
(I use openDNS: http://www.opendns.com/)
#/etc/dhcpd.conf
default-lease-time 600;
max-lease-time 7200;
#Change the following to the DNS from your ISP or use openDNS
option domain-name-servers 208.67.222.222, 208.67.220.220;
#I don't need this but if I wanted an internal web server or something via FQDN...
option domain-name "nomad.int";
#Subnet for DHCP clients
subnet 10.1.1.0 netmask 255.255.255.0 {
#Range of 10 machines - If you need more, increase the range
range 10.1.1.20 10.1.1.29;
option subnet-mask 255.255.255.0;
option broadcast-address 10.1.1.255;
option routers 10.1.1.1;
}
DHCP failed to work properly, that's when I forgot that DHCP listens for address requests on the first physical NIC and I still need it to work with wireless (eth0 is dead). That means it needs to work with the virtual bridge connecting eth2 (LAN) to ath0 (Wireless) - So that wireless connections can communicate on the network, which in turn can communicate with the Internet. Edit the DCHP file:
sudo nano /etc/default/dhcp
And add the bridge:
INTERFACES="br0"
Everything should be done now.
After restarting - a cold restart get's the whole thing working - (I had to reboot and restart a few times before writing this - I made a few mistakes), everything should work.
A case in point, I'm posting this blog through the new (temporary) wireless connection. Now I'm happy. Besides... It's Friday!!
If you like this post, why not share it?
  • StumbleUpon
  • del.icio.us
  • Digg
  • Google Bookmarks
  • Reddit
  • Mixx
  • Yahoo! Bookmarks
  • blogmarks
  • Twitter
Related posts:
  1. Using Ubuntu to Crack WEP
  2. Installing an Ubuntu Linux Hardy 8.04 LAMP and FFMpeg Server With a GUI – LAMP installation with cgi-bin
  3. Make Your Own Plug ‘N Play Zone Using Ubuntu Linux!
  4. Ubuntu Needs to Improve the Network Management GUI!
  5. How to regularly backup Windows XP to Ubuntu, using rsync
kw: mesh, networking, freedom, p2p, internet, bitcoin, asterisk, google, google voice, android, root, free, wireless, data, linux, voip, voice

No comments:

Post a Comment