LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux > 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

Tags used in this thread
Popular LQ Tags , ,

Reply
 
Thread Tools
Old 09-14-2009, 12:30 PM   #1
saiyen2002
LQ Newbie
 
Registered: Dec 2006
Posts: 2
Thanked: 0
Question packet coming through one interface route out via another interface and SNAT also


[Log in to get rid of this advertisement]
I have box1 with ip 192.168.129.10 ang GW 192.168.129.1
This box also has an alias of 172.16.0.1

i have the ip of another box, box2 to 172.16.0.10 and the GW to 172.16.0.1, but box2 can not reach the internet. It can ping both ips of box1 but no internet.

the 172.16.0.0 network is not currently catered for in my company.

I am thinking that if i can create some iptable NAT rules on box1 that will accept any packets coming in on 172.16.0.1 and then send it out through 192.168.129.10, at the same time changing the source ip to 192.168.129.10 since 172.16.0 network is not catered for.

I dont know if my idea is possible, if it is how do i implement this on iptables.

If it doesn't work, other solutions are welcome.

thanks
windows_vista saiyen2002 is offline  
Tag This Post , ,
Reply With Quote
Old 09-14-2009, 01:42 PM   #2
estabroo
Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 657
Blog Entries: 2
Thanked: 18
you need to turn on ip forwarding as well echo 1 > /proc/sys/net/ipv4/ip_forward (typically you can set it permanently in your sysctl.conf file)

then just add a rule like iptables -t nat -A POSTROUTING -o eth0 -s 172.16.0.10 -j MASQUERADE
linuxdebian estabroo is offline     Reply With Quote
Thanked by:
Old 09-14-2009, 07:56 PM   #3
saiyen2002
LQ Newbie
 
Registered: Dec 2006
Posts: 2
Thanked: 0

Original Poster
Thumbs up

It Works, thanks estabroo

I have modified it a little

iptables -t nat -A POSTROUTING -o eth0 -s 172.16.0.0/24 -j SNAT --to-source 192.168.129.1

from my scouring through the internet, masquerade is for dynamically assigned ip's and SNAT is better suited for static IP's.

Last edited by saiyen2002; 09-14-2009 at 09:10 PM..
windows_xp_2003 saiyen2002 is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
network interface not coming backup after reboot noir911 Linux - Server 2 02-11-2009 12:03 AM
SNAT with virtual interface not working rajat83 Linux - Networking 1 08-14-2008 12:34 AM
Route port 25 to interface eth2 ajaimes Linux - Networking 8 06-27-2007 03:39 AM
why i see same packet twice on network interface? cranium2004 Linux - Networking 6 11-26-2004 10:42 AM
How to get the IP header of packet going through an interface thanh Programming 1 06-12-2004 01:26 PM


All times are GMT -5. The time now is 04:21 AM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration