Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
This is my first try configuring a linux box to serve as an internet server for about 75 PCs in our office. I am using a Red Hat Linux 9 distribution with kernel 2.4.20-8, and iptables ver. 1.2.7a. I need to create a customized iptables script to allow our private network to access the internet using NAT or masquerading since we have only one official IP address assigned. The built-in iptables file in the directory /etc/sysconfig/iptables cannot be customized. It can only be modified with its features using the "lokkit" utility for allowing incoming packets such as HTTP and Mail but it has no feature for doing NAT or MASQUERADING. I tried manually editing the /etc/sysconfig/iptables file and did a /etc/init.d/iptables restart but it did not work. It only issued a "Bad argument 'iptables'" error and a "Try 'iptables-restore' and a [FAILED] message instead of [OK] it if started normal. How do I go about this? I replaced the built-in iptables file with the one I created but it also does not work. Please advise.
The /etc/sysconfig/iptables file shouldn't ever be directly modified. It's extremely sensitive to syntax and certain rules will not work even if the syntax is 100% correct. Instead enter the iptables rules on the command line, verify that everything works to your liking, then do service iptables save. That will modify the iptables file for you.
FWIW, you should just need to do something like this from the commandline (as root):
iptables -A POSTROUTING -o <external_interface> -j MASQUERADE
May or may not need these as well:
iptables -I FORWARD -i <external_interface> -o <internal_interface> -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -I FORWARD -i <internal_interface> -o <external_interface> -j ACCEPT
Also make sure that packet forwarding is on:
echo 1 > /proc/sys/net/ipv4/ip_forward