![]() |
Gateway server - how to configure NICs and iptables to control Internet access
Hi,
I am trying to setup an Internet gateway/router to provide security and control access to the Internet on a medium sized network. I have read so much about IP masqurading, NATing and adding routes that I'm a little bit confused about exactly what I need to be doing. First: The Current Setup
Second: The Proposed Setup
Third: The Questions
For Your Reference: /etc/network/interfaces Code:
# This file describes the network interfaces available on your system |
Normally getting intranet hosts to reach internet is not that difficult.
It only requires (basically) two steps: masquerading traffic going out to the internet interface: Code:
iptables -t nat -A POSTROUTING -o internetinterface -j MASQUERADECode:
sysctl -w net.ipv4.ip_forward=1Then comes the mess of filtering. Traffic coming from one network interface and going out of the host will have to traverse the FORWARD chain in the FILTER tables. For a server that is going to be connected to internet I'd recommend to set a DROP policy for INPUT and FILTER and then start adding rules to allow traffic on those chains.... a very clear example is to allow traffic moving in the loopback interface: Code:
iptables -P FILTER DROPI normally set up all this netfilter crap in a single script (starting by setting the policies, flushing all the rules and create everything from scratch) and call it from rc.local so that it's set up when the host boots up... and if I need to add/edit/remove something I edit the script and call it. Hope that helps. |
Hi eantoranz,
Thank you very much for your help. One of the commands you supplied is giving me an error: Code:
iptables --policy FILTER DROPCode:
iptables: Bad built-in chain name. |
You're right. It's FORWARD, not FILTER. FORWARD and INPUT.
|
INPUT is traversed by packets that are meant for the host. FORWARD is traversed by packets that are received by this host but are meant for another.
|
| All times are GMT -5. The time now is 12:37 PM. |