LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-01-2007, 05:45 AM   #1
zoltrix
Member
 
Registered: Oct 2004
Distribution: Fedora 11, Ubuntu 9.04, RHEL 4,5 ,Centos 5.1
Posts: 45

Rep: Reputation: 15
NAT / Gateway problem


I use Fedora 7 and my /etc/sysconfig/iptables is as follows

Quote:
# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:FORWARD ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -i ppp1 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -d 224.0.0.251 --dport 5353 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m state -m udp --dport 51115 --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state -m tcp --dport 51115 --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m state -m udp --dport 9176 --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state -m tcp --dport 9176 --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m state -m udp --dport 1090 --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state -m tcp --dport 1090 --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state -m tcp --dport 2425 --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m state -m udp --dport 2425 --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state -m tcp --dport 80 --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state -m tcp --dport 443 --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Generated by webmin
*mangle
:FORWARD ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A PREROUTING -i ppp1 -j MARK --set-mark 0x9
COMMIT
# Completed
# Generated by webmin
*nat
:OUTPUT ACCEPT [0:0]
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -m mark -j MASQUERADE --mark 0x9
COMMIT
# Completed

now my interface connected to internet is ppp0
interface between my phone and computer is ppp1 (using bluetooth and DUN)

i want the phone to access internet through ppp0 . The above firewall config worked for me in FC5 , but it refusing to work in Fedora7. Please help....

I also ran the following command before trying to connect

Quote:
/sbin/sysctl net.ipv4.conf.all.forwarding=1
 
Old 07-01-2007, 06:44 AM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Oh yeah, the redhat firewall... note: sudo iptables -L usually gives easier to read information.

... what you have is (apparently) a default accept policy for everything (bad), but all inputs get sent to the redhat defined chain (puzzling, but allows for more elaborate firemalls with extra chains). The redhat chain goes on to accept pretty much everything.

The firewall is too complicated to check easily, and it is a wonder it stops anything at all.

Here's a script that has been known to work
http://www.linuxquestions.org/questi...36#post2224036

The IP Forwarding section can be replaced with the following to use masquerading rather than a direct approach used above.
http://www.linuxquestions.org/questi...52#post2790552

Execute the script, then run:
iptables-save > /etc/sysconfig/iptables

Remember to make the alterations to suit your system: eg.
WEBFACE=ppp0
LANFACE=ppp1

But, of course, why would you suspect the firewall?

Last edited by Simon Bridge; 07-01-2007 at 06:56 AM.
 
Old 07-01-2007, 08:45 AM   #3
zoltrix
Member
 
Registered: Oct 2004
Distribution: Fedora 11, Ubuntu 9.04, RHEL 4,5 ,Centos 5.1
Posts: 45

Original Poster
Rep: Reputation: 15
Thanks Simon, the script worked really well. Though If you have the time, can anyone tell me what was wrong in the earlier setup i was trying !?
 
Old 07-01-2007, 12:23 PM   #4
gr8scot
Member
 
Registered: Jun 2007
Distribution: Debian, kubuntu
Posts: 73

Rep: Reputation: 16
what was wrong in the earlier setup

Quote:
Originally Posted by zoltrix
Thanks Simon, the script worked really well. Though If you have the time, can anyone tell me what was wrong in the earlier setup i was trying !?
-A PREROUTING -i ppp1 -j MARK --set-mark 0x9
COMMIT
# Completed
# Generated by webmin
*nat
:OUTPUT ACCEPT [0:0]
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -m mark -j MASQUERADE --mark 0x9

I believe that the problem was in applying the masquerade rule to the interface on the lan side of your firewall machine. You could try running the same rule set, with "ppp1" on the first line I copied changed to "ppp0", your internet interface, if you want to identify the problem. There may be other problems, but that looks like a necessary change to get your previous script to work.
 
Old 07-01-2007, 05:31 PM   #5
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Yep... it had to be something like that.
If the original script was just copied over there wouldn't have been a problem. But it looks like you were doing it from memory or notes rather than backup.

It is very easy to mix up the interface names like that. Another common mixup is to make a loop where two or more chains pass a packet back and forth forever.

Anyway, using (intelligently named) variables in the script is a kind of discipline which can avoid this sort of confusion.

Of course I could have just told you... I just chose to act in your best interests by solving the meta-problem first. You'll find that script very easy to understand and modify as your needs change. It also gives a more secure firewall... though you may need to explicitly open a port sometimes.


btw ${interface}, I think, needs to be $WEBFACE
 
  


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
NAT/Gateway setup cflyguy Linux - Networking 3 08-11-2005 11:47 PM
?pure? gateway (no nat) and more problems... dacleric Linux - Networking 1 10-07-2004 04:56 PM
IPTABLES NAT Gateway, No Access from the inside? nweaver916 Linux - Networking 2 08-27-2004 03:46 PM
workgroup / NAT gateway question ?!?!?! Josh328 Linux - Networking 1 04-28-2004 03:38 PM
proxy server thru nat gateway. tanmay_79 Linux - General 1 09-10-2001 07:45 AM

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

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