Ubuntu as Router setup help needed

IpX

New Member
Joined
Aug 18, 2003
Messages
3
Reaction score
0
Location
Centurion, South Africa.
Hi all,

I know this is a hot topic and I have read most of the posts. It helped a lot but I still have a few issue. Below is my setup and what I'm trying to accomplish.

I have a Ubuntu 10.042 box with 2 network cards. a Linksys WAG120N ADSL modem (4 port with wireless). I want to have all my other computers, including the ones using wireless use the ubuntu box as the gateway. I also have setup 2 ADSL accounts (International and Local) (I used the tubleweed Tutorial, my modem is not supported so no DD-WRT).

Currently I have setup the 2 ppp (0 & 1) devices. They seem to work and I imported the local routes from http://mene.za.net/za-routes/latest.txt. I am able to connect the modem (I plug both network cards into the modem), other computers (including wireless) can surf through it when I setup static ip's and use the linux box ip as the gateway. I have the following 2 Issues:.

1. I have to manually setup the connection after reboot. My eth0 is not shown in ifconfig after reboot. I have to ifup eth0 to get it going. I also added a static ip address (192.168.0.101) to eth0. I setup all my ppp (0 & 1) to use eth1 for dialing. Also only one ppp is connected. I have to bring it down and then manually bring both up.

2. When I have internet access then I am unable to see my shared folders. They are on a Windows 7 computer but was accessible before I connected to the internet. When I am not connected I can see my folders and work on them. This is important as I have a media player connected that uses shared folders.
I think it has something to do with the eth0. I need to tell the network to use that device for local network traffic and the eth1 for internet and the gateway.

Any help would be appreciated. I may have gotten things messed up because I was following so many FAQ's to try and fix it.
 
I'd suggest that you rather get the list of local routes from http://developers.locality.co.za/splitting
Use one of the CIDR formatted ones. You can pretty much just port Gatecrasher's DD-WRT script to work on Ubuntu to split the traffic.

Make sure that you use a subnet mask of 255.255.255.0 (aka /24 subnet) for your eth0. If you don't do that, then you will have issues accessing the shared folders of your LAN PC's.

You will also have to enable masquerading on the ppp interfaces, which you can do by running 'iptables -t nat -A POSTROUTING -o ppp+ -j MASQUERADE'. Please note that this change will not be permanent, so you'll have to read up on iptables-save.

The gateway won't work until you've enabled TCP/IP v4 forwarding too by performing the steps shown here: http://worka.blogspot.com/2006/01/ubuntu-enable-ipv4-forwarding.html

If you haven't enabled masquerading & forwarding, then you should have traffic splitting working on the gateway itself, but the clients behind the gateway won't have Internet access at all.
 
I'd suggest that you rather get the list of local routes from http://developers.locality.co.za/splitting
Use one of the CIDR formatted ones. You can pretty much just port Gatecrasher's DD-WRT script to work on Ubuntu to split the traffic.

Make sure that you use a subnet mask of 255.255.255.0 (aka /24 subnet) for your eth0. If you don't do that, then you will have issues accessing the shared folders of your LAN PC's.

You will also have to enable masquerading on the ppp interfaces, which you can do by running 'iptables -t nat -A POSTROUTING -o ppp+ -j MASQUERADE'. Please note that this change will not be permanent, so you'll have to read up on iptables-save.

The gateway won't work until you've enabled TCP/IP v4 forwarding too by performing the steps shown here: http://worka.blogspot.com/2006/01/ubuntu-enable-ipv4-forwarding.html

If you haven't enabled masquerading & forwarding, then you should have traffic splitting working on the gateway itself, but the clients behind the gateway won't have Internet access at all.

I will have a look at the setup of eth0. I followed atleast 2 threads where you give advice on how to set this up so I believe the forwarding and masquerading is working. I connected with the gateway and surfed local and then international sites and constantly checked the usage on the ppp0 and ppp1 devices. They changed accordingly and as I expected. (This was done from another pc, not the gateway ubuntu box)

I will give feedback on my findings later tonight. Thanks for the feedback and help. I was hoping you would reply as you are clearly the expert on this...
 
Unfortunately I don't have that much experience with setting up a headless Ubuntu as a gateway, because I'm running RouterOS in a VirtualBox VM to act as my gateway.

If you're stuck again, I'd suggest that you pm me with 'ifconfig', 'route -n | grep -v -e ppp1', 'iptables -t nat -L -v -n' & 'iptables -t filter -L -v -n' results.

You might actually want to use mangle rules and different routing tables for splitting traffic, because at this moment your main routing table would contain ~700 routes - which is why I want you to filter out the ppp1 routes (which would be your local interface) with that grep command ;)
 
Top
Sign up to the MyBroadband newsletter
X