LinuxQuestions.org
Visit Jeremy's Blog.
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 07-27-2010, 01:53 AM   #1
tr1pl3x
LQ Newbie
 
Registered: Jul 2010
Distribution: Ubuntu 10.4, Fedora 13
Posts: 25

Rep: Reputation: 16
Unhappy Iptables manual masquerade problem


Gud day.I have a problem with my iptables setup.. hope you guys can help me.. Actually I already did masqueraded my connections so that my xp clients can view browse the internet by using firestarter as my firewal, but the point is i'm trying to masquerade my connections manually by not using firestarter or any gui firewall, im trying to remove firestarter and just write a script for my personal firewall.

here's what i've done so far by using the iptables, but masquerading didn't seems to work for me. by the way I'm using Ubuntu 10.04 LTS as my Linuxserver.

here's my setup..
LAN<<eth0<<linuxserver>>eth1>>Internet

#iptables -P INPUT DROP
#iptables -P OUTPUT ACCEPT
#iptables -P FORWARD DROP

//Allowing services for dnsmasq,dhcp server & webserver

#iptables -A INPUT -p tcp --dport 67 -j ACCEPT
#iptables -A INPUT -p tcp --dport 68 -j ACCEPT
#iptables -A INPUT -p udp --dport 67 -j ACCEPT
#iptables -A INPUT -p udp --dport 68 -j ACCEPT
#iptables -A INPUT -p tcp --dport 67 -j ACCEPT
#iptables -A INPUT -p tcp --dport 80 -j ACCEPT
#iptables -A INPUT -p tcp --dport 67 -j ACCEPT
#iptables -A INPUT -p tcp --dport 53 -j ACCEPT

//Allow loopback connections

#iptables -A INPUT -i lo -j ACCEPT

//Allow Established related connections for the local server
#iptables -A INPUT -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT

//Tried Masquerading?

#iptables -t nat -A POSTROUTING -s 192.168.0.1/24 -o eth1 -j MASQUERADE
#iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
#iptables -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT

Is there anything i'm missing here so that my clients can successfully browse the internet??.. need some advice, tnx in advance






im trying to masquerade my connections so that i can able to let my xpclients w/in my network to browse the internet..
 
Old 07-27-2010, 03:28 AM   #2
zirias
Member
 
Registered: Jun 2010
Posts: 361

Rep: Reputation: 59
Quote:
Originally Posted by tr1pl3x View Post
#iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
First, I'd drop that one. It would just allow SYN packets accidently using a port that the masquerading module has seen as internal source port. Under normal conditions, they will be just ignored by whatever host they are reaching, but it's unnecessary to "let them in".

edit:

Misread your interface names .. this line seems fine as it allows packets from the internal to the external interface. So maybe you just need to exchenge the interface names on the NEXT line where packets belonging to established connections are allowed.

/edit.

And then, one thing often overlooked when trying to set up a masquerading router is the fact the linux network stack has to be configured to route /at all/. Try
Code:
sysctl net.ipv4.ip_forward
If it says
Code:
net.ipv4.ip_forward = 0
your box doesn't act as a router. Edit /etc/sysctl.conf or some file in /etc/sysctl.d/ to change this permanently (and issue "sysctl -w net.ipv4.ip_forward=1" to switch routing on instantly).

Another idea: Are all these '#' charcaters actually in your script? '#' starts a comment, so these lines would be ignored.

If this doesn't help, maybe describe in detail what behavior you expected and what you got...

Last edited by zirias; 07-27-2010 at 03:30 AM.
 
Old 07-27-2010, 07:13 AM   #3
tr1pl3x
LQ Newbie
 
Registered: Jul 2010
Distribution: Ubuntu 10.4, Fedora 13
Posts: 25

Original Poster
Rep: Reputation: 16
Smile

Quote:
your box doesn't act as a router. Edit /etc/sysctl.conf or some file in /etc/sysctl.d/ to change this permanently (and issue "sysctl -w net.ipv4.ip_forward=1" to switch routing on instantly).
i already did that by issuing the

echo 1> /proc/sys/net/ipv4/ip_forward

& I also edited the /etc/sysctl.conf by changing the line

net.ipv4.ip_forward = 0 to net.ipv4.ip_forward = 1

i just forgot to put it in my 1st post..
secondly the eth1 & eth0 is correct I set it up that way.

the eth0 is my internal interface while the eth1 is my outbound interface going to the internet.

the number sign '#' is just to let you know that im trying to type it in textbased using user as root.

As of now I'm using firestarter to setup masquerading correctly. however im still trying to create my own script w/out the help of the firestarter.

heres some more info bout my connection.


nternet->
DSLmodem->
eth1-LinuxServer-eth0->
LAN

can you give me some info on how to do this by the way im newbie to linux??.. What needs modification from the script that I created above??

Last edited by tr1pl3x; 07-27-2010 at 07:17 AM.
 
Old 07-27-2010, 07:17 AM   #4
zirias
Member
 
Registered: Jun 2010
Posts: 361

Rep: Reputation: 59
Quote:
Originally Posted by zirias View Post
So maybe you just need to exchenge the interface names on the NEXT line where packets belonging to established connections are allowed.
See, your rule from the first post allows packets in state "ESTABLISHED" and "RELATED" from eth0 to eth1 (from inside to outside), but it really SHOULD allow these packets in the other direction (from eth1 to eth0). Maybe this is the whole problem.
 
Old 07-27-2010, 07:19 AM   #5
tr1pl3x
LQ Newbie
 
Registered: Jul 2010
Distribution: Ubuntu 10.4, Fedora 13
Posts: 25

Original Poster
Rep: Reputation: 16
Quote:
//Allow Established related connections for the local server
#iptables -A INPUT -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT
what do you mean about this rule??.. ok I will try to remove this one

Last edited by tr1pl3x; 07-27-2010 at 07:20 AM.
 
Old 07-27-2010, 07:58 AM   #6
zirias
Member
 
Registered: Jun 2010
Posts: 361

Rep: Reputation: 59
No i meant you should exchange eth0 and eth1 on that rule because you want to allow these packes from the outside world (internet) to the inside...

But please understand I'll stop supporting this issue unless some nazi "moderator" reconsiders his behavior.
 
0 members found this post helpful.
Old 07-27-2010, 10:10 AM   #7
pcangelo
LQ Newbie
 
Registered: Jul 2010
Posts: 8

Rep: Reputation: 0
My point of view is that you have some issues in FORWARD chain

- you set the policy to DROP
- you allow the forwarding like : -i eth0 -o eth1 -j ACCEPT, but I am not sure that at this level the eth1 is known. In my opinion, if am not wrong, the eth1 will be known only later after the output routing table.
 
  


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
[SOLVED] iptables? masquerade? digger86 Linux - Networking 5 06-26-2009 05:44 PM
iptables masquerade nat portforwarding problem borborygmis Linux - Networking 5 08-14-2008 01:51 AM
client email problem with iptables masquerade amado Linux - Networking 2 10-13-2004 10:46 AM
iptables masquerade deconfliction ttucker Linux - Networking 15 08-01-2004 06:04 PM
Masquerade - iptables amphion Linux - Security 6 06-08-2003 09:59 PM

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

All times are GMT -5. The time now is 11:52 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