LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 05-05-2006, 06:22 PM   #1
PeteRossi
Member
 
Registered: Jun 2002
Location: Southeast PA
Distribution: Slackware
Posts: 40

Rep: Reputation: 15
Can I IP MASQUERADE as more than one address?


It is possible to IP masquerade different hosts on the "internal" network
to different addresses on the "external" network?

I currently have a common configuration like this.

............ gateway box
DSL------>eth1 eth0<-------internal 192.1.68.1.0 network.

I have IP masquerade with a static DSL address and everything works fine.
Been doing it for years.




I would like to do this:

.................... gateway box
DSL x.y.z.1 ----->eth1 eth0<---------internal 192.168.1.0 network
DSL x.y.z.2 ----->eth1:0
eth1:0 set up with alias


I want all boxes except 192.168.1.8 to be masqueraded as x.y.z.1 and
192.168,1.8 to be masqueraded as x.y.z.2


I set up the following IPTABLES rules...

iptables -A FORWARD -i eth1 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
iptables -A FORWARD -i eth1:0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth0 -o eth1:0 -j ACCEPT

iptables -t nat -A POSTROUTING -s 192.168.1.8 -o eth1:0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 192.168.1.18 -o eth1 -j MASQUERADE


IP MASQUERADE for 192.168.1.18 is working fine. For now there are only 2 boxes
on the internal network so to keep things simple I just put the rule in for 18
only. But 192.168.1.8 will not work. This box was working OK before when I
was just doing the simple masquerading for all boxes on the internal network.

Am what I am trying to do possible? I would think it should be.
I guess I am doing something wrong but haven't figured it out yet.

Last edited by PeteRossi; 05-05-2006 at 06:29 PM.
 
Old 05-05-2006, 06:27 PM   #2
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
This looks sort of like what you're after. Maybe the links will help out...
 
Old 05-05-2006, 06:47 PM   #3
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 65
Iptables can only understand real network interfaces and not virtual network interfaces. What you need to do is use the IP address instead of the eth0:0 for what you are doing.

Brian1
 
Old 05-24-2006, 06:33 PM   #4
Droo
LQ Newbie
 
Registered: Aug 2003
Location: London
Distribution: Slackware
Posts: 7

Rep: Reputation: 0
Not sure if you've solved this but since you've got static IP's you may be able to do something similar to me:

Code:
/usr/sbin/iptables -t nat -p all -A POSTROUTING -s 192.168.1.8/32 -j SNAT --to-source x.y.z.2
/usr/sbin/iptables -t nat -p all -A POSTROUTING -s 192.168.1.0/24 -o eth1 -j MASQUERADE
 
  


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
Masquerade nanoprobe Linux - Networking 7 06-12-2005 08:48 AM
how to get ip address, broadcast address, mac address of a machine sumeshstar Programming 2 03-12-2005 04:33 AM
IP Masquerade qbik Slackware 3 09-11-2003 03:02 PM
IP Masquerade help armcfall Linux - Networking 6 06-24-2003 09:06 AM
About masquerade Nuts Linux - Networking 8 08-30-2002 09:56 AM

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

All times are GMT -5. The time now is 01:05 AM.

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