LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-03-2009, 09:40 PM   #1
stevenworr
LQ Newbie
 
Registered: Oct 2008
Posts: 13

Rep: Reputation: 1
Solution: NAT failure unless firewall is started twice


I'm running Fedora 10, so your mileage may vary. This is a problem I recently solved and thought that others might benefit from it.

I have a server with two NICs. My eth0 goes to my cable modem and eth1 goes to the internal network. Also, eth0 is the gateway for network.

If the server is freshly booted then the internal network machines can not see the outside world. But the network became visible if the firewall was rebooted. Also, note that the firewall was the same both before and after restart.

The solution terms out to be the following:

In /etc/sysctl.conf, this must be set.

net.ipv4.ip_forward = 1

otherwise NAT won't function. In my case, the firewall was actually setting ip_forward to the correct value, but the network service script was resetting all kernel params based on the content of /etc/sysctl.conf.

So, the old sequence went like this at boot

firewall start # ip_forward turned on
network start # ip_forward turned off
firewall restart # ip_forward turned back on.


Now with the setting properly set in sysctl.conf, the startup works correctly.
 
Old 03-04-2009, 02:55 AM   #2
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by stevenworr View Post
I'm running Fedora 10, so your mileage may vary. This is a problem I recently solved and thought that others might benefit from it.

I have a server with two NICs. My eth0 goes to my cable modem and eth1 goes to the internal network. Also, eth0 is the gateway for network.

If the server is freshly booted then the internal network machines can not see the outside world. But the network became visible if the firewall was rebooted. Also, note that the firewall was the same both before and after restart.

The solution terms out to be the following:

In /etc/sysctl.conf, this must be set.

net.ipv4.ip_forward = 1

otherwise NAT won't function. In my case, the firewall was actually setting ip_forward to the correct value, but the network service script was resetting all kernel params based on the content of /etc/sysctl.conf.

So, the old sequence went like this at boot

firewall start # ip_forward turned on
network start # ip_forward turned off
firewall restart # ip_forward turned back on.


Now with the setting properly set in sysctl.conf, the startup works correctly.
It seems like a fairly common newbie mistake to believe that the iptables service script will take care of enabling IP forwarding. As you've found out, that isn't the case. The sysctl.conf suggestion you've made is pretty much the standard way of making sure IP forwarding is enabled. Another option would be to echo into /proc from a startup script (such as rc.local).
 
Old 03-05-2009, 09:15 AM   #3
stevenworr
LQ Newbie
 
Registered: Oct 2008
Posts: 13

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by win32sux View Post
It seems like a fairly common newbie mistake to believe that the iptables service script will take care of enabling IP forwarding. As you've found out, that isn't the case. The sysctl.conf suggestion you've made is pretty much the standard way of making sure IP forwarding is enabled. Another option would be to echo into /proc from a startup script (such as rc.local).
Just to be clear, the firewall was setting ip_forward but the networking script which comes after the firewall at boot time was actually re-executing the sysctl.conf file. That re-execution was shutting ip_forward off. I am not using the iptables service at all; I'm using another firewall. Prior to Fedora 10, I had no need to set ip_forward in the conf file.
 
Old 03-05-2009, 11:46 AM   #4
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by stevenworr View Post
Just to be clear, the firewall was setting ip_forward but the networking script which comes after the firewall at boot time was actually re-executing the sysctl.conf file. That re-execution was shutting ip_forward off. I am not using the iptables service at all; I'm using another firewall. Prior to Fedora 10, I had no need to set ip_forward in the conf file.
Thanks for the clarification. They most likely prefer it if people use the actual iptables service, with which you'll need to edit sysctl.conf anyway. But if you didn't see this behavior before then it could be a bug I guess. You could break your script into two sections, one for iptables commands and one for setting kernel parameters (which you'd place further down the startup, like in rc.local, for example). Although, honestly, the cleanest choice IMHO is indeed sysctl.conf.

BTW, why aren't you using the iptables service?

Last edited by win32sux; 03-05-2009 at 11:49 AM.
 
Old 03-05-2009, 11:12 PM   #5
stevenworr
LQ Newbie
 
Registered: Oct 2008
Posts: 13

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by win32sux View Post
Thanks for the clarification. They most likely prefer it if people use the actual iptables service, with which you'll need to edit sysctl.conf anyway.

BTW, why aren't you using the iptables service?
I doubt that there are any theys who would have any preference for how or whether I set up my firewall. There are a number of firewall encapsulations out there for iptables. The one I use is something called fiaif, for Fiaif Is An Intelligent Firewall. It's easy to configure and it gives very fine controls.
 
Old 03-05-2009, 11:33 PM   #6
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by stevenworr View Post
I doubt that there are any theys who would have any preference for how or whether I set up my firewall.
LOL! Good point.

Quote:
There are a number of firewall encapsulations out there for iptables. The one I use is something called fiaif, for Fiaif Is An Intelligent Firewall. It's easy to configure and it gives very fine controls.
You should check in with their mailing list to see what's up.

I mean, if FIAIF is supposed to let you set kernel parameters, and they are getting reset, that's a bug.

Last edited by win32sux; 03-05-2009 at 11:45 PM.
 
  


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
LXer: Getting Started With Firewall Builder LXer Syndicated Linux News 0 02-25-2009 09:40 AM
Looking for a solution to disk failure! florence1000 Linux - Hardware 1 05-16-2008 03:57 AM
firewall behind a nat wrat Linux - Security 3 06-15-2004 11:28 AM
large file download failure solution bpw DamnSmallLinux 0 03-02-2004 11:58 PM
firewall and nat nakkaya Linux - Networking 3 02-25-2004 08:58 AM

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

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