Now that I've got my NEC Ready 340T up and running to my satisfaction, it's time to attack the meat of my reason for doing so in the first place -- to establish a reliable firewall for a home network.
After doing much reading on iptables, but finding few examples of firewall scripts that were not highly complicated, I decided to just go ahead and write my own, which follows. I have a few questions (there may be some overlap in the answers): First, when I set the the INPUT policy to "DROP", I am unable to ping external IP addresses from the firewall or anywhere from behind it (although pings to the internal network from the firewall work fine). Can someone tell me how to remedy this? It seems to me that having that policy in place is essential to firewall security... Second, when I un-comment the ICMP line (under OUTPUT "4"), pinging anywhere from the firewall experiences or from the internal network to the firewall gives 100% packet loss, although the internal network is still able to ping external IP addresses fine. Is there a way to remedy this easily? Given that the internal network can still see the external IP's, this seems less than critical for operation, but I'd still like to be able to ping directly from the firewall if internal machines have problems for any reason... Third, how many of the policies that I have set must I change to "DROP" to have a reasonably secure firewall? Fourth, does anyone have any general comments on how anything I have done here might be better implemented? In particular I am wondering whether I have properly established a "pipeline" through the firewall to the "JBOY" machine or whether either one of the PREROUTING or FORWARD rules I have written to accomplish the task can be better written (or possibly eliminated?) Comments are included so you know what I'm trying to accomplish. Thanks in advance for any help... Hagn # hagn.firewall # # (eth0 is external interface, eth1 internal) # =========================================== # # Set commands IPTABLES="/sbin/iptables" # Set generic addresses ANY="0/0" JBOY="10.0.0.2" # Firewall External (Internet) Address EXT_IP="`ifconfig eth0 | grep inet | cut -d : -f 2 | cut -d " " -f 1`" # Flush "filter" table $IPTABLES -F # Delete all non-"filter" tables $IPTABLES -X # Set policies on "filter" table $IPTABLES -P INPUT ACCEPT $IPTABLES -P OUTPUT ACCEPT $IPTABLES -P FORWARD ACCEPT # Set policies on "nat" table $IPTABLES -t nat -P PREROUTING ACCEPT $IPTABLES -t nat -P POSTROUTING ACCEPT $IPTABLES -t nat -P OUTPUT ACCEPT # INPUT rules # ----------- # 0. Accept all connections from the loopback interface $IPTABLES -A INPUT -i lo -j ACCEPT # 1. Accept telnet requests from internal network $IPTABLES -A INPUT -p tcp --syn -i eth1 --dport 23 -j ACCEPT # 2. Accept FTP requests from internal network $IPTABLES -A INPUT -p tcp --syn -i eth1 --dport 20 -j ACCEPT $IPTABLES -A INPUT -p tcp --syn -i eth1 --dport 21 -j ACCEPT # 3. Accept Half-life server requests from any network # (I intend to set up a game server on the firewall machine itself) $IPTABLES -A INPUT -p tcp -s $ANY --dport 27015 -j ACCEPT $IPTABLES -A INPUT -p udp -s $ANY --dport 27015 -j ACCEPT # 4. Let all other tcp requests and ICMP requests hit the floor $IPTABLES -A INPUT -p tcp --syn -j DROP # $IPTABLES -A INPUT -p icmp -j DROP # FORWARD rules # ------------- # 1. Forward FTP and Gnutella connection requests to J-Boy's machine $IPTABLES -A FORWARD -p tcp -i eth0 -o eth1 -d $JBOY --dport 20 -j ACCEPT $IPTABLES -A FORWARD -p tcp -i eth0 -o eth1 -d $JBOY --dport 21 -j ACCEPT $IPTABLES -A FORWARD -p tcp -i eth0 -o eth1 -d $JBOY --dport 6347 -j ACCEPT # 2. Forward internal network packets to external network $IPTABLES -A FORWARD -i eth1 -j ACCEPT $IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT # OUTPUT rules # ------------ # 1. Allow packets out through the loopback $IPTABLES -A OUTPUT -o lo -j ACCEPT # ============ # PRE/POSTROUTING # --------------- # 1. Forward external FTP and Gnutella requests to J-Boy's machine $IPTABLES -t nat -A PREROUTING -p tcp -i eth0 -d $EXT_IP --dport 20 -j DNAT\ --to $JBOY:20 $IPTABLES -t nat -A PREROUTING -p tcp -i eth0 -d $EXT_IP --dport 21 -j DNAT\ --to $JBOY:21 $IPTABLES -t nat -A PREROUTING -p tcp -i eth0 -d $EXT_IP --dport 6347 -j DNAT\ --to $JBOY:6347 # 2. Disguise internal network packets bound for the external network # as packets from the firewall machine's IP address $IPTABLES -t nat -A POSTROUTING -o eth0 -j SNAT --to-source $EXT_IP $IPTABLES -t nat -A POSTROUTING -o eth1 -j ACCEPT # Non-IPTABLES Stuff # ------------------ # 1. Enable kernel packet forwarding echo 1 > /proc/sys/net/ipv4/ip_forward _______________________________________________ Redhat-list mailing list [EMAIL PROTECTED] https://listman.redhat.com/mailman/listinfo/redhat-list
