Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Ralf Spenneberg <lists@spenneberg.org>
To: robert.cole@support4linux.com
Cc: Netfilter <netfilter@lists.netfilter.org>
Subject: Re: 3 part firewall
Date: 21 May 2003 21:15:17 +0200	[thread overview]
Message-ID: <1053544517.1913.24.camel@kermit.spenneberg.de> (raw)
In-Reply-To: <200305202342.51581.robert.cole@support4linux.com>

Am Mit, 2003-05-21 um 08.42 schrieb Robert Cole:
> Like David T I'm a bit frustrated myself. :)
Ok. let's see.
> 
> The flexiblity of iptables has got me pulling my hair out. Here's what I would 
> like to do:
> 
> I have a server that has 3 real interfaces (no aliases). eth0 is the public, 
> eth1 is the private and eth2 is the DMZ interface. All the books and docs 
> I've seen so far work with only two interfaces and trying to adapt those 
> scripts is giving me a headache.
> 
> I want to allow all private traffic out to the internet through PAT (port 
> address translation). But when going from the LAN to the DMZ I want no nat or 
> pat going on, only when leaving to the internet. 
Ok.
DMZ_DEV=eth2
PRV_DEV=eth1
PUB_DEV=eth0
# making up the network, replace as needed.
PRV_NET=192.168.0.0/24
DMZ_NET=192.168.1.0/24
# NAT rules
iptables -t nat -A POSTROUTING -s $PRV_NET -o $PUB_DEV -j MASQUERADE
> 
> Next I would like a strict rule that allows another public IP to be 1 to 1 
> nat'd from the public interface to a server out the DMZ interface.
PUB_IP=128.176.0.12
DMZ_IP=192.168.1.15
iptables -t nat -A POSTROUTING -i $PUB_DEV -d $PUB_IP -j DNAT --to
$DMZ_IP

So far we have setup the NAT rules, now the filtering.
# Allow all established connections
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

# Allow traffic from the private network to the DMZ
iptables -A FORWARD -i $PRV_DEV -o $DMZ_DEV -s $PRV_NET -d $DMZ_NET -m
state --state NEW -j ACCEPT

# Allow traffic from the private network to the internet
iptables -A FORWARD -i $PRV_DEV -o $PUB_DEV -s $PRV_NET -d 0/0 -m state
--state NEW -j ACCEPT

# Allow traffic from the outside to the one machine on the DMZ
iptables -A FORWARD -i $PUB_DEV -o $DMZ_DEV -s 0/0 -d $DMZ_IP -m state
--state NEW -j ACCEPT

# Close everything else (you might want to move these rules to the
beginning
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

# Be aware that you cannot access the firewall anymore and the firewall
cannot access any other machine.
# Turn on forwarding 
sysctl -w net.ipv4.ip_forward=1


> 
> 
> Any ideas?
This should get you going. Email again if you've got problems.

Cheers,

Ralf
-- 
Ralf Spenneberg
RHCE, RHCX

Book: Intrusion Detection für Linux Server   http://www.spenneberg.com
IPsec-Howto				     http://www.ipsec-howto.org
Honeynet Project Mirror:                    
http://honeynet.spenneberg.org


      parent reply	other threads:[~2003-05-21 19:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-21  6:42 3 part firewall Robert Cole
2003-05-21 10:08 ` Julian Gomez
2003-05-21 11:00   ` Oskar Andreasson
2003-05-21 10:35 ` David Trott
2003-05-21 19:15 ` Ralf Spenneberg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1053544517.1913.24.camel@kermit.spenneberg.de \
    --to=lists@spenneberg.org \
    --cc=netfilter@lists.netfilter.org \
    --cc=robert.cole@support4linux.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox