LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-17-2010, 08:37 AM   #1
Evstrati
LQ Newbie
 
Registered: Jan 2009
Posts: 24

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


Hello,

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

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

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

Any ideas? Thanks
E
 
Old 02-17-2010, 11:27 AM   #2
sarin
Member
 
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, 12:21 PM   #3
Evstrati
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.

Thanks

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

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

Code:
iptables -A forwarding_wan -s xxx.xxx.153.142 -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
 
  


Reply



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 09:01 AM
Policy based routing, leaking packets tetra Linux - Networking 0 04-22-2009 02:15 AM
Problem routing packets through network jccurtis Linux - Networking 3 12-16-2005 08:10 AM
Routing Local Packets qs_tahmeed Linux - Networking 1 11-16-2005 10:30 PM
Resending packets (routing) Barca Linux - Networking 7 11-13-2004 03:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:33 PM.

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