Lunarhotel.co.uk

How about a view of the sea of tranquility?
Home Linux stuff Part 1: Routing over two Internet connections with Linux - Finishing Off
E-mail
Print
PDF
Written by Web Master   
Sunday, 16 August 2009 13:47
User Rating: / 4
PoorBest 
Article Index
Part 1: Routing over two Internet connections with Linux
Setting up a simple router
Routing Tables
Finishing Off
All Pages

So run your updated router.sh and you should now have a router which routes ftp traffic over INTERNET CONNECTION B and all other traffic over INTERNET CONNECTION A. its difficult to get any visual confirmation that its actually working. To test mine, I simply visited www.whatismyip.com and noted my public ip address. I then changed the above rule so that tcp port 80 traffic was routed over the B connection, and revisted www.whatismyip.com and made sure that they changed. Oh! and one other thing: Dont try run the above test on the router itself. If you goto www.whatismyip.com on there, it will always report the public ip address of the default connection in the MAIN table. It only seems to work from a client pc. If anyone can offer any ideas as to why this might be, Im all ears

And there we have it! Just like we did with the firewall rules, you might want to put all of the commands which set up the secondary routing table, and define the ip rules into a sh script. Again, it makes it easier for debugging as we go along, and if you reboot your router, the secondary routing table (tbr) and the ip rule will be lost.

Conclusion

So theres still a lot to do on this. What Ive detailed here is just one possible application of multiple internet connections. As mentioned in the intro, theres lots of other configs we could use including load balancing over the two connections, automatic fail over (so when one fails the other kicks in) Of course we can expand on what rules we've defined so that can have all port 80 traffic (http) going over the quicker 2mb line, and all email (not so time critical) going out via the 512k line. Or even Email comes in on the 512k line, but gets sent on the 2mb line. Ive read (although never attempted) that you can even create rules based on the user thats logged in, giving rise to situations like "IT Department gets to use fast line, everyone else can slum it on the slow line" Which while cruel, is something I think alot of us would like to do!

Check out Part2 where we deal with incoming connections like a webserver, or a mailserver .

UPDATE: at the end of part 3 there is a small discussion on changing which connection a given traffic type gets router over on the fly (e.g. not having to reload the router script everytime you want to make a change) Its best to read part two to get a full idea of how it all works. But if you really cant wait, part 3 is here.

 

 



Last Updated on Friday, 06 November 2009 11:19
 

Comments  

 
+1 # Mihai Joldes 2009-11-06 10:38
nice script!
As i am new to linux and want to setup just what you explained here (w/o load balancig tho), it comes handy!

I was wandering if the 3'rd line from the bottom up is correct (-i $ INTERNETIFA ). Shouldn't it be -i $INTERNETIFB ?
I know i'm new, but since your script helped me, i just wanna help out too :)
 
 
# Web Master 2009-11-06 11:30
Quoting Mihai Joldes:
nice script!
As i am new to linux and want to setup just what you explained here (w/o load balancig tho), it comes handy!

I was wandering if the 3'rd line from the bottom up is correct (-i $ INTERNETIFA ). Shouldn't it be -i $INTERNETIFB ?
I know i'm new, but since your script helped me, i just wanna help out too :)


Mihai,
Welcome to lunarhotel.co.uk. You are quite right! Ive made the change. Well done for spotting it. And well done for having a go at Linux.
The script in its current state doesnt actually support load balancing however. It was something I was looking at doing, but sadly with world-wide recession in full swing, my IT department has had to make cut backs (Like only one internet connection! ) However, as a result Im also happy to report that with a few tweaks of the script's constants, it works with a single internet connection too... but just as a standard firewall / router obviously.

If you have anymore thoughts / ideas for the script, please let me know.
 

You must register if you wish to comment

Its official! usernames suck!

12507Check out the 10 mile round trip I had to do to login into a site that was asking for a username and password

Whos online

We have 22 guests online

Joomla EmailAsUsername Testamonials

"Thanks for a great plugin, and speedy helpful support."

"I really appreciate how responsive you have been and I want to reward you by adding a very positive comment on the Joomla site where I found your great plugin"

"Wow, tested it out and works like a champ"

"I had a couple of installation issues which Dylan sorted for me the same afternoon. Superb service for the price."

"Thank you!!!  Best support I have ever had!"

"Thank you soooooo much for your time and effort on this, you're a life saver!....If your ever in the London or Guildford area I'll get the beers in!"