public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user]  iptables example on Gentoo
@ 2005-09-06 17:22 James
  2005-09-06 17:39 ` Dave Nebinger
  0 siblings, 1 reply; 41+ messages in thread
From: James @ 2005-09-06 17:22 UTC (permalink / raw
  To: gentoo-user

Hello,

I've been trying to build a simple firewall with a DMZ for a 
web server.
x.x.x.x is the local single static IP y.y.y.y is the gateway IP.
z.z.z.z is the broadcast.
Outward access is working (ip and dns) Currently the dns servers
I use are the cable modem company's, and they work just fine,
for now. I can download packages and ebuilds just fine. Access
to the mail servers outside the network works just fine.

Note: I have an openbsd firewall with a dmz & web server, and all
works just fine. It's disconnected while I try to get this gentoo
firewall working with the same web server and other lan components.

Following this simple example:
http://www.gentoo.org/doc/en/home-router-howto.xml

Here's what I did to add a DMZ based web server:

A. (3) ethernet interfaces are setup via ifconfig and are working.

B. /etc/conf.d.net
        I added these lines:
iface_eth0="192.168.2.20 broadcast 192.168.2.255 
netmask 255.255.255.0"
iface_eth1="192.168.3.11 broadcast 192.168.3.255 
netmask 255.255.255.0"
iface_eth2="x.x.x.x broadcast z.z.z.z 
netmask 255.255.255.252"
routes_eth2=( "default gw y.y.y.y" )

C. and here's the IP tables portion:
Start with ' iptables -F'  and 'iptables -t nat -F'



 export LAN=eth0
  export DMZ=eth1
  export WAN=eth2
  iptables -I INPUT 1 -i ${LAN} -j ACCEPT
  iptables -I INPUT 1 -i lo -j ACCEPT
  iptables -A INPUT -p UDP --dport bootps -i !
       ${LAN} -j REJECT
  iptables -A INPUT -p UDP --dport domain -i !
       ${LAN} -j REJECT
  iptables -A INPUT -p TCP -i ! ${LAN} -d 0/0 
       --dport 0:1023 -j DROP
  iptables -A INPUT -p UDP -i ! ${LAN} -d 0/0 
      --dport 0:1023 -j DROP
  iptables -I FORWARD -i ${LAN} -d 
       192.168.0.0/255.255.0.0 -j DROP
  iptables -A FORWARD -i ${LAN} -s 
      192.168.0.0/255.255.0.0 -j ACCEPT
  iptables -A FORWARD -i ${WAN} -d 
      192.168.0.0/255.255.0.0 -j ACCEPT
  iptables -t nat -A POSTROUTING -o 
      ${WAN} -j MASQUERADE
iptables -t nat -A PREROUTING -p tcp 
      --dport 80 -i ${WAN} -j DNAT --to 192.168.3.11

D. Next:
echo 1 > /proc/sys/net/ipv4/ip_forward
  for f in /proc/sys/net/ipv4/conf/*/rp_filter ;
        do echo 1 > $f ; done

E. And finishing with:
  /etc/init.d/iptables save  
  rc-update add iptables default
  vi /etc/sysctl.conf
Add/Uncomment the following lines:
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 1

Questions
Step C: Qestion 1:

The rule I added:
iptables -t nat -A PREROUTING -p tcp 
      --dport 80 -i ${WAN} -j DNAT --to 192.168.3.11

Does not give access to the web server, either from the outside
internet, nor from the interlan lan. Can somebody fix the rule
or tell me what I've done wrong or what is additionally needed?


Here are the error messages:
Warning: wierd character in interface `-j' (No aliases, :, ! or *).
Bad argument `DNAT'

Question 2:
Where are the config files, built by iptables (filter, nat,
 mangle,
 raw)
and is it OK to just edit these manually, trying various rules
and testing the results? Any other files to edit directly?

I've read about shorewall, but I prefer to
directly edit these files (and any others I have missed) directly
while I learn/test the features of iptables/netfilter. Shorewall
or any other gui, is for later, when I've develop a 
certain confidence
via understanding how iptables/netfilter works.

This is only a simple network, I'm setting up to mostly to 
learn about
iptables/netfilter. Any help or comments is appreciated. I intend
to slowly add features and rules and to test along the way, as 
to satisfy my
curiousity while learning firewalling on linux based systems.

James

-- 
gentoo-user@gentoo.org mailing list



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

end of thread, other threads:[~2005-09-10 17:19 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-06 17:22 [gentoo-user] iptables example on Gentoo James
2005-09-06 17:39 ` Dave Nebinger
2005-09-06 17:53   ` Holly Bostick
2005-09-06 18:25     ` [gentoo-user] " James
2005-09-06 19:04       ` Dave Nebinger
2005-09-06 20:00         ` James
2005-09-06 20:39           ` Dave Nebinger
2005-09-07  0:02         ` gentuxx
2005-09-07  1:20           ` W.Kenworthy
2005-09-07 13:08           ` Dave Nebinger
2005-09-07 17:06             ` James
2005-09-07 18:14               ` Holly Bostick
2005-09-07 19:11                 ` James
2005-09-07 19:53                   ` Dave Nebinger
2005-09-08 18:14                     ` James
2005-09-08 19:30                       ` kashani
2005-09-07 20:09                   ` Holly Bostick
2005-09-07 18:40               ` gentuxx
2005-09-07 19:29                 ` James
2005-09-07 19:56                   ` gentuxx
2005-09-07 20:49                     ` Dave Nebinger
2005-09-07 18:48               ` Dave Nebinger
2005-09-07 22:08                 ` James
2005-09-07 23:51                   ` gentuxx
2005-09-08  1:23                     ` James
2005-09-08  9:20                       ` Neil Bothwick
2005-09-08 17:43                         ` James
2005-09-08 16:19                           ` James
2005-09-08 16:42                           ` Dave Nebinger
2005-09-09  9:44                             ` Michael Kintzios
2005-09-09 13:38                               ` Dave Nebinger
2005-09-08 17:35                           ` Neil Bothwick
2005-09-09  0:52                       ` Jerry McBride
2005-09-07 23:52               ` Rumen Yotov
2005-09-07 18:48                 ` James
2005-09-07 19:44   ` [gentoo-user] " Bryan Whitehead
2005-09-08  1:34     ` [gentoo-user] " James
2005-09-08 15:37       ` Rumen Yotov
2005-09-09 11:19   ` [gentoo-user] " Timo Boettcher
2005-09-09 14:23     ` Dave Nebinger
2005-09-10 17:04       ` Timo Boettcher

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