LinuxQuestions.org
Help answer threads with 0 replies.
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 12-17-2005, 05:46 AM   #1
GeoSava
LQ Newbie
 
Registered: Dec 2005
Posts: 5

Rep: Reputation: 0
MASQUERADE only one interface


Hello to all i am almost new in Linux but i have managed to install a slackware distribution in my old Celeron.

I want to use this Linux Box as a router in my network but i have a little problem.

The PC has 3 ethernet adapters.

Two simple ethernet and one wireless ethernet.
They are all working properly.

Its ethernet is a different subnet.

Till now i have working using iptables with the command:

iptables -t nat -A POSTROUTING -o $EXTERNAL -j MASQUERADE

EXTERNAL is my eth0

to enable NAT and share internet form may main subnet where the proxy is located to the other two subnets....

I want to ask if there is a way to route one subnet without NAT and enable NAT only to the other subnet??



Thanxs!!!

Last edited by GeoSava; 12-17-2005 at 05:48 AM.
 
Old 12-17-2005, 08:37 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
just use a -i eth1 as well. so rather than just stating where the traffic is heading, you state where it came from too.
 
Old 12-19-2005, 05:41 AM   #3
GeoSava
LQ Newbie
 
Registered: Dec 2005
Posts: 5

Original Poster
Rep: Reputation: 0
Thanxs for your answer

I have tried to do that but it seems that i am doing something wrong.

Can you help me with the command syntax??
 
Old 12-19-2005, 09:33 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
help with what? just do the exact same command but adding the -i option too.
 
Old 12-20-2005, 05:16 AM   #5
GeoSava
LQ Newbie
 
Registered: Dec 2005
Posts: 5

Original Poster
Rep: Reputation: 0
I have tryied to execute the command

iptables -t nat -A POSTROUTING -o eth0 -i wlan0 -j MASQUERADE

and i take an error message that i cannot use the -i option in the POSTROUTING Chain.

If i use PREROUTING Chain i cannot use the -o option.

I have understand what you say: something like that
iptables -A FORWARD -o eth0 -i wlan0 -j ACCEPT
which works but it does not work with the "-t nat" option and POSTROUTING.

Can you try it yourself and possibly find a solution?

Thank you very much.
 
Old 12-20-2005, 05:32 AM   #6
roopunix
Member
 
Registered: Feb 2004
Location: Kathmandu
Distribution: Redhat/fedora/Suse [Wanna Drive With Debian]
Posts: 208

Rep: Reputation: 30
what abt this

ptables -t nat -A POSTROUTING -i wlan0 - eth0 -j MASQUERADE
 
Old 12-20-2005, 07:25 AM   #7
GeoSava
LQ Newbie
 
Registered: Dec 2005
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
iptables -t nat -A POSTROUTING -i wlan0 - eth0 -j MASQUERADE
I will try this when i get at home!!! But i beleive that the answer will be again that i cannot use the "-i option" with the POSTROUTING Chain of iptables.

Thanxs for the recommendation. I will give feedback.
 
Old 12-20-2005, 08:13 PM   #8
SirGertrude
Member
 
Registered: May 2004
Location: Missouri
Distribution: Gentoo
Posts: 59

Rep: Reputation: 15
You cannot use the "-i" option in the postrouting chain because after routing there will not be an incoming interface to associate with. Are you sure you want to route one network and masquerade another? If you do not have public IP's on the routed network it will not do you any good to route it... unless you have a more complex network scheme we don't know about. Assuming you really want to route one network you will want to use the "-s" option with iptables to define the source network to masquerade. Example:
Code:
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE
This will masquerade the entire 192.168.1.0 network and everything else will be routed.
 
Old 02-03-2006, 09:36 AM   #9
GeoSava
LQ Newbie
 
Registered: Dec 2005
Posts: 5

Original Poster
Rep: Reputation: 0
Thanxs SirGertrude your command work just fine.....

Sorry I haven't replay all this time. My router works fine for about 2-3 months now.

:-) :-D
 
  


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
question about masquerade Tearless Linux - Networking 3 11-13-2003 02:25 PM
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 04:42 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