problem with dmz firewall script - cant connect to inet via plan
From: bob (bob@kr8.co.uk)
Date: 12/10/02
- Next message: steve harris: "Re: problem with dmz firewall script - cant connect to inet via plan"
- Previous message: Nico Kadel-Garcia: "Re: Really headache on antispam!"
- Next in thread: steve harris: "Re: problem with dmz firewall script - cant connect to inet via plan"
- Reply: steve harris: "Re: problem with dmz firewall script - cant connect to inet via plan"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: bob@kr8.co.uk (bob) Date: 9 Dec 2002 17:40:00 -0800
Hi,
can anyone tell me why my firewall script is not working correctly.
Everything is fine but I can not access the internet from my private
lan. I have a dmz and seperate trusted private lan multihomed on the
firewall box connected to the internet via a dsl connection. The
external interface card is aliased with real ip addresses and dnat'ed
through to the dmz. The box runs linux redhat 7.2 and I am using
iptables (userspace) as my packet filter. I have looked at this for a
while but am now at a loss for further testing. The strange thing is
that windows clients on the private lan have internet access ok but
when I try to connect a linux client to the internet via the private
lan it does not work. Does the static route table have to be set up as
normal on the private lan box ? i.e. add host, networks and default
gateway - if so should I be able to ping the dsl router via the
firewall ?
I have included my firewall script :
#!/bin/sh
# rc.DMZ.firewall - DMZ IP Firewall script for Linux 2.4.x and
iptables
# 1. Configuration options.
######### Internet Configuration.
INET_IP="81.2.94.210"
HTTP_IP="81.2.94.211"
DNS_IP="81.2.94.212"
INET_IFACE="eth0"
######## Local Area Network configuration.
LAN_IP="192.168.0.2"
LAN_IP_RANGE="192.168.0.0/16"
LAN_BROADCAST_ADDRESS="192.168.0.255"
LAN_IFACE="eth1"
######## Display status information
echo "---------------------------------------------------------"
echo "HTTP IP: $HTTP_IP"
echo "DNS IP: $DNS_IP"
echo "External Network Device: $INET_IP"
echo "External IP: $INET_IP"
echo "Local Network Address: $LAN_IP"
echo "---------------------------------------------------------"
ALLOW_ICMP="0 3 4 5 8 11 12"
######## DMZ Configuration.
DMZ_HTTP_IP="192.168.1.3"
DMZ_DNS_IP="192.168.1.4"
DMZ_IP="192.168.1.2"
DMZ_IP_RANGE="192.168.1.0/16"
DMZ_IFACE="eth2"
######## Localhost Configuration.
LO_IFACE="lo"
LO_IP="127.0.0.1"
# IPTables Configuration.
IPTABLES="/sbin/iptables"
# Other Configuration.
# Module loading.
# Needed to initially load modules
/sbin/depmod -a
# 2.1 Required modules
/sbin/modprobe ip_tables
/sbin/modprobe ip_conntrack
/sbin/modprobe iptable_filter
/sbin/modprobe iptable_mangle
/sbin/modprobe iptable_nat
/sbin/modprobe ipt_LOG
/sbin/modprobe ipt_limit
/sbin/modprobe ipt_state
# 2.2 Non-Required modules
#/sbin/modprobe ipt_owner
#/sbin/modprobe ipt_REJECT
#/sbin/modprobe ipt_MASQUERADE
#/sbin/modprobe ip_conntrack_ftp
#/sbin/modprobe ip_conntrack_irc
#/sbin/modprobe ip_nat_ftp
#/sbin/modprobe ip_nat_irc
# 3. /proc set up.
# 3.1 Required proc configuration
echo "1" > /proc/sys/net/ipv4/ip_forward
# 3.2 Non-Required proc configuration
#echo "1" > /proc/sys/net/ipv4/conf/all/rp_filter
#echo "1" > /proc/sys/net/ipv4/conf/all/proxy_arp
#echo "1" > /proc/sys/net/ipv4/ip_dynaddr
# Rules set up.
###### FILTER TABLE ############
# Set policies
$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT DROP
$IPTABLES -P FORWARD DROP
# Create userspecified chains
# Create chain for bad tcp packets
$IPTABLES -N bad_tcp_packets
# Create separate chains for ICMP, TCP and UDP to traverse
$IPTABLES -N allowed
$IPTABLES -N icmp_packets
$IPTABLES -N tcp_packets
$IPTABLES -N udpincoming_packets
# Create content in userspecified chains
# bad_tcp_packets chain
$IPTABLES -A bad_tcp_packets -p tcp ! --syn -m state --state NEW -j
LOG \
--log-prefix "New not syn:"
$IPTABLES -A bad_tcp_packets -p tcp ! --syn -m state --state NEW -j
DROP
# allowed chain
$IPTABLES -A allowed -p TCP --syn -j ACCEPT
$IPTABLES -A allowed -p TCP -m state --state ESTABLISHED,RELATED -j
ACCEPT
$IPTABLES -A allowed -p TCP -j DROP
# ICMP rules
# Changed rules totally
$IPTABLES -A icmp_packets -p ICMP -s 0/0 --icmp-type 0 -j ACCEPT
$IPTABLES -A icmp_packets -p ICMP -s 0/0 --icmp-type 8 -j ACCEPT
$IPTABLES -A icmp_packets -p ICMP -s 0/0 --icmp-type 11 -j ACCEPT
######## INPUT chain ############
# Bad TCP packets we don't want
$IPTABLES -A INPUT -p tcp -j bad_tcp_packets
# Packets from the Internet to this box
$IPTABLES -A INPUT -p ICMP -i $INET_IFACE -j icmp_packets
# Packets from LAN, DMZ or LOCALHOST
# From DMZ Interface to DMZ firewall IP
$IPTABLES -A INPUT -p ALL -i $DMZ_IFACE -d $DMZ_IP -j ACCEPT
# From LAN Interface to LAN firewall IP
$IPTABLES -A INPUT -p ALL -i $LAN_IFACE -d $LAN_IP_RANGE -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LAN_IFACE -d $LAN_BROADCAST_ADDRESS -j
ACCEPT
# From Localhost interface to Localhost IP's
$IPTABLES -A INPUT -p ALL -i $LO_IFACE -s $LO_IP -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LO_IFACE -s $LAN_IP_RANGE -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LO_IFACE -s $INET_IP -j ACCEPT
# Special rule for DHCP requests from LAN, which are not caught
properly
# otherwise.
$IPTABLES -A INPUT -p UDP -i $LAN_IFACE --dport 67 --sport 68 -j
ACCEPT
# All established and related packets incoming from the internet to
the
# firewall
#
$IPTABLES -A INPUT -p ALL -d $INET_IP -m state --state
ESTABLISHED,RELATED \
-j ACCEPT
# Log weird packets that don't match the above.
$IPTABLES -A INPUT -m limit --limit 3/minute --limit-burst 3 -j LOG \
--log-level DEBUG --log-prefix "IPT INPUT packet died: "
######## FORWARD chain ###########
# Bad TCP packets we don't want
$IPTABLES -A FORWARD -p tcp -j bad_tcp_packets
## DMZ section
## General rules
$IPTABLES -A FORWARD -i $DMZ_IFACE -o $INET_IFACE -j ACCEPT
$IPTABLES -A FORWARD -i $INET_IFACE -o $DMZ_IFACE -m state \
--state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -i $LAN_IFACE -o $DMZ_IFACE -j ACCEPT
$IPTABLES -A FORWARD -i $DMZ_IFACE -o $LAN_IFACE -j ACCEPT
#set up allow traffic from lan to inet and back again
$IPTABLES -A FORWARD -i $LAN_IFACE -o $INET_IFACE -j ACCEPT
$IPTABLES -A FORWARD -i $INET_IFACE -o $LAN_IFACE -m state \
--state ESTABLISHED,RELATED -j ACCEPT
## HTTP server
$IPTABLES -A FORWARD -p TCP -i $INET_IFACE -o $DMZ_IFACE -d
$DMZ_HTTP_IP \
--dport 80 -j allowed
$IPTABLES -A FORWARD -p ICMP -i $INET_IFACE -o $DMZ_IFACE -d
$DMZ_HTTP_IP \
-j icmp_packets
$IPTABLES -A FORWARD -p TCP -i $INET_IFACE -o $DMZ_IFACE -d
$DMZ_HTTP_IP \
-s 0/0 --dport 22 -j allowed
## DNS server
$IPTABLES -A FORWARD -p TCP -i $INET_IFACE -o $DMZ_IFACE -d
$DMZ_DNS_IP \
--dport 53 -j allowed
$IPTABLES -A FORWARD -p UDP -i $INET_IFACE -o $DMZ_IFACE -d
$DMZ_DNS_IP \
--dport 53 -j ACCEPT
$IPTABLES -A FORWARD -p ICMP -i $INET_IFACE -o $DMZ_IFACE -d
$DMZ_DNS_IP \
-j icmp_packets
## LAN section
$IPTABLES -A FORWARD -p TCP -i $LAN_IFACE -j ACCEPT
$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
## Log weird packets that don't match the above.
$IPTABLES -A FORWARD -m limit --limit 3/minute --limit-burst 3 -j LOG
\
--log-level DEBUG --log-prefix "IPT FORWARD packet died: "
######## OUTPUT chain ############
# Bad TCP packets we don't want.
$IPTABLES -A OUTPUT -p tcp -j bad_tcp_packets
# Special OUTPUT rules to decide which IP's to allow.
$IPTABLES -A OUTPUT -p ALL -s $LO_IP -j ACCEPT
$IPTABLES -A OUTPUT -p ALL -s $LAN_IP_RANGE -j ACCEPT
$IPTABLES -A OUTPUT -p ALL -s $INET_IP -j ACCEPT
# Log weird packets that don't match the above.
$IPTABLES -A OUTPUT -m limit --limit 3/minute --limit-burst 3 -j LOG \
--log-level DEBUG --log-prefix "IPT OUTPUT packet died: "
### nat table
### Set policies
### Create user specified chains
### Create content in user specified chains
######## PREROUTING chain ##############
# send packets from internet to web server
$IPTABLES -t nat -A PREROUTING -p TCP -i $INET_IFACE -d $HTTP_IP
--dport 80 -j DNAT --to-destination $DMZ_HTTP_IP
$IPTABLES -t nat -A PREROUTING -p TCP -i $INET_IFACE -d $DNS_IP
--dport 53 -j DNAT --to-destination $DMZ_DNS_IP
$IPTABLES -t nat -A PREROUTING -p UDP -i $INET_IFACE -d $DNS_IP
--dport 53 -j DNAT --to-destination $DMZ_DNS_IP
$IPTABLES -t nat -A PREROUTING -p TCP -i $INET_IFACE -d $HTTP_IP
--dport 22 -j DNAT --to-destination $DMZ_HTTP_IP
$IPTABLES -t nat -A PREROUTING -p TCP -i $LAN_IFACE -d $INET_IP
--dport 80 -j DNAT --to-destination $INET_IP
###### POSTROUTING chain ##############
# Enable simple IP Forwarding and Network Address Translation
$IPTABLES -t nat -A POSTROUTING -o $INET_IFACE -j SNAT --to-source
$INET_IP
## OUTPUT chain
# mangle table
# Set policies
# Create user specified chains
# Create content in user specified chains
# PREROUTING chain
# INPUT chain
# FORWARD chain
# OUTPUT chain
# POSTROUTING chain
many thanks,
james fox
- Next message: steve harris: "Re: problem with dmz firewall script - cant connect to inet via plan"
- Previous message: Nico Kadel-Garcia: "Re: Really headache on antispam!"
- Next in thread: steve harris: "Re: problem with dmz firewall script - cant connect to inet via plan"
- Reply: steve harris: "Re: problem with dmz firewall script - cant connect to inet via plan"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|