Register a domain and help support LQ
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 12-22-2009, 11:14 AM   #1
LQ Newbie
Registered: Mar 2009
Posts: 12

Rep: Reputation: 0
iptables: marking packets for routing to two default gateways


I am new to iproute2 and iptables and want to ask the experts here a question:

I have a machine on one network and two routers on the same network. I have to give an "application" (written in C) the choice of using any of the two routers as default gateways.

Right now I am changing the default gateway on the machine using system() call in C, based upon the input to the application. But I would like to have some nice solution.

I thought of creating two default routes using iptables with different tables numbers, marking the packets using iptables and setting the routing rules accordingly for the different marked packets. But the problem is that I cannot mark the packets in C code or can I? Usuallly, they are marked using iptables command.

I wonder if there is a best way to do this. I would really appreciate the responses.



Last edited by obaidmushtaq; 12-22-2009 at 11:17 AM. Reason: Spells
Old 01-13-2010, 06:28 PM   #2
Registered: Feb 2007
Location: Iceland
Distribution: Fedora 14, CentOS, FreeNAS
Posts: 126

Rep: Reputation: 20
2 gateways?

Not sure I understand you right or why you need this but you might want to look at load balancing or failover. There are some threads about that, if not here then google it. Might also be called multiwan.
Old 01-19-2010, 10:01 AM   #3
LQ Newbie
Registered: Mar 2009
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks, I figured out that we can use libnetfilter_queue to do this but I want a non-GPL solution. If you know it, please tell me. I will post a new message on appropirate forum for it.





Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
marking ARP packets with ebtables problem mgautam Linux - Networking 0 10-19-2009 05:34 AM
iptables marking question. netstv Linux - Networking 0 03-26-2009 12:36 PM
iptables packet marking and hfsc xanax Linux - Networking 0 02-19-2007 12:43 AM
On-demand PPP, routing, gateways, and iptables godofpumpkins Linux - Networking 1 10-10-2005 11:46 AM
iptables packet marking meks Linux - Networking 0 09-21-2004 06:14 PM

All times are GMT -5. The time now is 01:51 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration