Support LQ: Use code LQ3 and save $3 on Domain Registration
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 02-17-2010, 09:37 AM   #1
LQ Newbie
Registered: Jan 2009
Posts: 24

Rep: Reputation: 0
iptables routing packets on the same sub-network


I am running into trouble while trying to set-up a iptables routing policy. I have two machines on the same sub-network ( One of the machines is used as a default gw for the other ( is a gateway for and is a gw for There is no explanation for why the is in the middle -- can go straight to, but is is like that for now.

I am trying to find an iptable rule to be executed on the machine to route the packets. I was trying something like:

iptables -A FORWARD -i eth0 -s -o eth0 -j ACCEPT
but it doesn't seem enough. I am running openwrt on

Any ideas? Thanks
Old 02-17-2010, 12:27 PM   #2
Registered: May 2001
Location: India, Kerala, Thrissur
Distribution: FC 7-10
Posts: 354
Blog Entries: 2

Rep: Reputation: 34
I think you need to explicitly tell 254 that gw to 142 is 250. Also, check if forwarding is on in /proc/sys/net/ipv4/ip_forward
Old 02-17-2010, 01:21 PM   #3
LQ Newbie
Registered: Jan 2009
Posts: 24

Original Poster
Rep: Reputation: 0
In fact this is the other way around -- 254 is the default gw of .250 (and 250 is the one of 142 even if it should be 254 in 'normal conditions').

The forwarding flag is set to 1. If I put a 'normal' router on the place of the OpenWRT it works straightforward. That's why I think it is a iptables related problem.


Last edited by Evstrati; 02-17-2010 at 01:22 PM. Reason: typo
Old 02-17-2010, 02:50 PM   #4
LQ Newbie
Registered: Jan 2009
Posts: 24

Original Poster
Rep: Reputation: 0
So my guess was correct. It works with

iptables -A forwarding_wan -s -o eth0.1 -j ACCEPT
I was not putting the correct forward chain (FORWARD instead of forwarding_wan). It is a bit weird, but it works...

Thanks anyway


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
iptables: marking packets for routing to two default gateways obaidmushtaq Linux - Networking 2 01-19-2010 10:01 AM
Policy based routing, leaking packets tetra Linux - Networking 0 04-22-2009 03:15 AM
Problem routing packets through network jccurtis Linux - Networking 3 12-16-2005 09:10 AM
Routing Local Packets qs_tahmeed Linux - Networking 1 11-16-2005 11:30 PM
Resending packets (routing) Barca Linux - Networking 7 11-13-2004 04:24 PM

All times are GMT -5. The time now is 12:23 AM.

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