Linux Netfilter discussions
 help / color / mirror / Atom feed
* RE: can someone check this simple firewall?
@ 2003-08-13 22:39 Daniel Chemko
  2003-08-15 17:55 ` Payal Rathod
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Chemko @ 2003-08-13 22:39 UTC (permalink / raw)
  To: Payal Rathod, netfilter

#!/bin/sh

LAN_IP_RANGE="192.168.10.0/24"
LAN_IP="192.168.10.100"
#LAN_BCAST_ADRESS="192.168.10.100"
LOCALHOST_IP="127.0.0.1"
STATIC_IP="1.2.3.4"
INET_IFACE="eth0"
LAN_IFACE="eth1"
IPTABLES="/sbin/iptables"

#/sbin/depmod -a
#/sbin/modprobe ipt_LOG
#/sbin/modprobe ipt_MASQUERADE
->> You probably want at least:
->> modprobe ipt_conntrack_ftp
->> modprobe ipt_nat_ftp


$IPTABLES -F
$IPTABLES -F -t nat

->> Set this AFTER you have setup all your rules, otherwise you have a
hole for hackers to reach through while applying rules
echo "1" > /proc/sys/net/ipv4/ip_forward
$IPTABLES -t nat -A POSTROUTING -o $INET_IFACE -j SNAT --to-source
$STATIC_IP

# MAKE DEFAULT AS DROP

$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT DROP
->> OUTPUT description below
$IPTABLES -P FORWARD DROP

# ACCEPT ANY CONNECTION FROM LAN
# ACCEPT CONNECTION TO ONLY 21, 22, 80 FROM OUTSIDE
# DENY REST
# ALLOW PING FROM EVERYWHERE

$IPTABLES -A INPUT -s $LAN_IP_RANGE -d $LAN_IP -j ACCEPT

$IPTABLES -A INPUT -s $LOCALHOST_IP -d $LAN_IP -j ACCEPT
$IPTABLES -A INPUT -s $LOCALHOST_IP -d 0/0 -j ACCEPT
->> Should instead be a related rule:
->> $IPTABLES -A INPUT -i lo -j ACCEPT # All Outbounds are ok
->> $IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT #
Allow valid responses back in

->>Only TCP connections, not UDP and -s 0/0 is redundant
$IPTABLES -A INPUT -p tcp -s 0/0  --dport 21 -j ACCEPT
$IPTABLES -A INPUT -p udp -s 0/0  --dport 21 -j ACCEPT
$IPTABLES -A INPUT -p tcp -s 0/0  --dport 22 -j ACCEPT
$IPTABLES -A INPUT -p udp -s 0/0  --dport 22 -j ACCEPT
$IPTABLES -A INPUT -p tcp -s 0/0  --dport 80 -j ACCEPT
$IPTABLES -A INPUT -p udp -s 0/0  --dport 80 -j ACCEPT
->> This will not work for responses. Use this as well:
->> $IPTABLES -A INPUT -p icmp --icmp-type 0 -j ACCEPT if you want
internet pings from the firewall to work
$IPTABLES -A INPUT -p icmp -s $LAN_IP_RANGE -j ACCEPT

# ALLOW LAN CLIENTS TO GO ANYWHERE ON NET

$IPTABLES -A FORWARD -i $LAN_IFACE -j ACCEPT
$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -p icmp -s $LAN_IP_RANGE -j ACCEPT
->> $IPTABLES -A FORWARD -p icmp --icmp-type 0 -j ACCEPT
$IPTABLES -A FORWARD -s 192.168.10.0/24 -m state --state NEW -j ACCEPT
->> What is covered in this line that the first forward line does not??

# ALLOW ANY CONNECTION FROM LINUX SERVER TO INTERNET
->> This section is not needed. Set:
->> iptables -P OUTPUT ACCEPT
$IPTABLES -A OUTPUT -p ALL -s $LOCALHOST_IP -j ACCEPT
$IPTABLES -A OUTPUT -p ALL -s $LAN_IP -j ACCEPT
$IPTABLES -A OUTPUT -p ALL -s $STATIC_IP -j ACCEPT
$IPTABLES -A OUTPUT -p icmp s 0/0 -j ACCEPT



^ permalink raw reply	[flat|nested] 7+ messages in thread
* can someone check this simple firewall?
@ 2003-08-14 18:28 Payal Rathod
  2003-08-13 18:58 ` Gavin Hamill
  2003-08-14 10:18 ` Ralf Spenneberg
  0 siblings, 2 replies; 7+ messages in thread
From: Payal Rathod @ 2003-08-14 18:28 UTC (permalink / raw)
  To: netfilter

Hi,
I have designed a simple firewall ruleset. Can someone please check
them? 
It is kept at http://payal.staticky.com/firewall-1.txt

[Thanks Ralf, I will reply to your mail a bit later when someone
cross-checks this too.]

The objective is as follows,

		eth0=1.2.3.4	
  +----------+      +----------+        +--------------+
  | INTERNET +------+ LINUX    +--------+ WINDOWS      |
  |          |      | FIREWALL |        |   CLIENTS    |
  +----------+      +----------+        +--------------+
		 eth1=192.168.10.100	192.168.10.0/25

Linux box is connected to net thru a permanent ip (1.2.3.4)

LAN users can go anywhere on net as well as Linux box.
So can the Linux box.
But from outside people can connect only to port 21, 22, 80 and can ping
the Linux box (to check whether it is alive or not). Rest everything is
blocked.

Can someone please check my ruleset and tell me whether it will achieve
my obective. I can test that box for very less time so have to do all
the work from a different machine and then copy that file to that Linux
box. Hence any help in finding problems will be appreciated.

Thanks and bye.
With warm regards,
-Payal

-- 
"Visit GNU/Linux Success Stories"
http://payal.staticky.com
Guest-Book Section Updated.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-08-15 17:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-13 22:39 can someone check this simple firewall? Daniel Chemko
2003-08-15 17:55 ` Payal Rathod
2003-08-14 19:36   ` Can someone please explain to a newbie? Stephen J. McCracken
  -- strict thread matches above, loose matches on Subject: below --
2003-08-14 18:28 can someone check this simple firewall? Payal Rathod
2003-08-13 18:58 ` Gavin Hamill
2003-08-14 10:18 ` Ralf Spenneberg
2003-08-14 11:01   ` Chris Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox