Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Nov 2000 17:56:12 -0500 (EST)
From:      thursday@altavista.net
To:        cjclark@alum.mit.edu
Cc:        freebsd-questions@freebsd.org
Subject:   re: your mail
Message-ID:  <00112617561277.08110@weba2.iname.net>

next in thread | raw e-mail | index | archive | help

--Boundary-=_OKWNlIDJEeNnUVlINZtiVOPgtkCI
Content-Type: Text/Plain
Content-Transfer-Encoding: 7bit
Content-Description: text, unencoded

>[Please wrap your lines at about 70 columns or so for 
>those of us with RFC compliant MUAs. All of your 
>paragraphs are on one line.]

Sorry about that; using iname's webmail client.

>> "Nov 25 13:44:47 saucer natd[147]: failed to write
>> packet back (Permission denied)
>> 
>> Nov 25 13:44:53 saucer last message repeated 4 times
>> "
>> 
>> My questions are: What's up with this? Is this due
>> to my firewall rules, or something else? I have log 
>>no set in /etc/natd.conf, and I'd rather not see
>> this message if it's not affecting performance. I 
>> never saw this before on my 3.4 system.

> This is due to a packet that was processed by >natd(8) being dropped later in the firewall rules.

>> If there are some relevant files I can attach to 
>> help troubleshooting, please let me know.

>For the 'failed to write packet back' problem, a copy
> of both
>rc.firewall and output of 'ipfw show' are good if you >still need help
>with those.

Well...after poking around a bit, I've determined that 
the 'natd failed to write packet back' messages occur
whenever there's a hit (from the outside world) on any 
of the websites hosted on this machine.

But, I don't know why natd is seeing these. 

I've attached my rc.firewall (note, the outside IP isn't my real IP) and the output of 'ipfw show' (at the bottom of rc.firewall).

Thanks!



----------------------------------------------------------------
Get your free email from AltaVista at http://altavista.iname.com
--Boundary-=_OKWNlIDJEeNnUVlINZtiVOPgtkCI
Content-Type: text/english
Content-Transfer-Encoding: 7bit
Content-Description: text, unencoded
Content-Disposition: inline; filename=rc.firewall

/sbin/ipfw -f flush
/sbin/ipfw add divert natd all from any to any via rl0
/sbin/ipfw add pass all from any to any

############
# Setup system for firewall service.
# $FreeBSD: src/etc/rc.firewall,v 1.19.2.2 1999/08/29 14:18:55 peter Exp $

# Suck in the configuration variables.
#if [ -f /etc/defaults/rc.conf ]; then
#	. /etc/defaults/rc.conf
if [ -f /etc/rc.conf ]; then
	. /etc/rc.conf
fi

############
# Define the firewall type in /etc/rc.conf.  Valid values are:
#   open     - will allow anyone in
#   client   - will try to protect just this machine
#   simple   - will try to protect a whole network
#   closed   - totally disables IP services except via lo0 interface
#   Unknown  - disables the loading of firewall rules.
#   filename - will load the rules in the given filename (full path required)
#
# For ``client'' and ``simple'' the entries below should be customized 
# appropriately.

############
#
# If you don't know enough about packet filtering, we suggest that you
# take time to read this book:
#
#	Building Internet Firewalls
#	Brent Chapman and Elizabeth Zwicky
#
#	O'Reilly & Associates, Inc
#	ISBN 1-56592-124-0
#	http://www.ora.com/
#
# For a more advanced treatment of Internet Security read:
#
#	Firewalls & Internet Security
#	Repelling the wily hacker
#	William R. Cheswick, Steven M. Bellowin
#
#	Addison-Wesley
#	ISBN 0-201-6337-4
#	http://www.awl.com/
#

if [ "x$1" != "x" ]; then
	firewall_type=$1
fi

############
# Set quiet mode if requested
if [ "x$firewall_quiet" = "xYES" ]; then
	fwcmd="/sbin/ipfw -q"
else
	fwcmd="/sbin/ipfw"
fi

############
# Flush out the list before we begin.
$fwcmd -f flush

############
# These rules are required for using natd.  All packets are passed to
# natd before they encounter your remaining rules.  The firewall rules
# will then be run again on each packet after translation by natd,
# minus any divert rules (see natd(8)).
if [ "X${natd_enable}" = X"YES" ]; then
        $fwcmd add divert natd all from any to any via ${natd_interface}
fi

############
# If you just configured ipfw in the kernel as a tool to solve network
# problems or you just want to disallow some particular kinds of traffic
# they you will want to change the default policy to open.  You can also
# do this as your only action by setting the firewall_type to ``open''.

# $fwcmd add 65000 pass all from any to any

############
# Only in rare cases do you want to change these rules
$fwcmd add 100 pass all from any to any via lo0
$fwcmd add 200 deny all from any to 127.0.0.0/8


# Prototype setups.
if [ "${firewall_type}" = "open" -o "${firewall_type}" = "OPEN" ]; then

	$fwcmd add 65000 pass all from any to any

elif [ "${firewall_type}" = "client" ]; then

    ############
    # This is a prototype setup that will protect your system somewhat against
    # people from outside your own network.
    ############

    # set these to your network and netmask and ip
    net="192.168.4.0"
    mask="255.255.255.0"
    ip="192.168.4.17"

    # Allow any traffic to or from my own net.
    $fwcmd add pass all from ${ip} to ${net}:${mask}
    $fwcmd add pass all from ${net}:${mask} to ${ip}

    # Allow TCP through if setup succeeded
    $fwcmd add pass tcp from any to any established

    # Allow setup of incoming email 
    $fwcmd add pass tcp from any to ${ip} 25 setup

    # Allow setup of outgoing TCP connections only
    $fwcmd add pass tcp from ${ip} to any setup

    # Disallow setup of all other TCP connections
    $fwcmd add deny tcp from any to any setup

    # Allow DNS queries out in the world
    $fwcmd add pass udp from any 53 to ${ip}
    $fwcmd add pass udp from ${ip} to any 53

    # Allow NTP queries out in the world
    $fwcmd add pass udp from any 123 to ${ip}
    $fwcmd add pass udp from ${ip} to any 123

    # Everything else is denied as default.


elif [ "${firewall_type}" = "simple" ]; then

# 'simple' firewall taken from www.mostgraveconcern.com/freebsd

# Outside interface network and netmask and ip
             oif="rl0"
             onet="212.17.132.0"
             omask="255.255.255.0"
             oip="212.17.132.172"

             # Inside interface network and netmask and ip
             iif="xl0"
             inet="192.168.1.0"
             imask="255.255.255.0"
             iip="192.168.1.1"

             # My ISP's DNS servers
             dns1="206.17.140.161"
             dns2="191.164.246.5"
	     

             # Stop spoofing
             ${fwcmd} add deny log all from ${inet}:${imask} to any in via ${oif}
             ${fwcmd} add deny log all from ${onet}:${omask} to any in via ${iif}

             # Stop RFC1918 nets on the outside interface
             ${fwcmd} add deny all from 10.0.0.0/8 to any via ${oif}
             ${fwcmd} add deny all from any to 10.0.0.0/8 out via ${oif}
             ${fwcmd} add deny all from 172.16.0.0/12 to any via ${oif}
             ${fwcmd} add deny all from any to 172.16.0.0/12 out via ${oif}
             ${fwcmd} add deny all from 192.168.0.0/16 to any via ${oif}
             ${fwcmd} add deny all from any to 192.168.0.0/16 out via ${oif}

             # Stop draft-manning-dsua-01.txt nets on the outside interface
             ${fwcmd} add deny log all from 0.0.0.0/8 to any via ${oif}
             ${fwcmd} add deny log all from any to 0.0.0.0/8 via ${oif}
             ${fwcmd} add deny log all from 169.254.0.0/16 to any via ${oif}
             ${fwcmd} add deny log all from any to 169.254.0.0/16 via ${oif}
             ${fwcmd} add deny log all from 192.0.2.0/24 to any via ${oif}
             ${fwcmd} add deny log all from any to 192.0.2.0/24 via ${oif}
             ${fwcmd} add deny log all from 224.0.0.0/4 to any via ${oif}
             ${fwcmd} add deny log all from any to 224.0.0.0/4 via ${oif}
             ${fwcmd} add deny log all from 240.0.0.0/4 to any via ${oif}
             ${fwcmd} add deny log all from any to 240.0.0.0/4 via ${oif}

             # Allow established connections
             ${fwcmd} add pass tcp from any to any established

             # Allow IP fragments to pass through
             ${fwcmd} add pass all from any to any frag


             ### TCP SETUP RULES

             # HTTP - Allow access to our web server
             ${fwcmd} add pass tcp from any to any 80 setup
	    
             # POP - Allow access to our POP3 server
	     ${fwcmd} add pass log tcp from any to any 110 setup

             # SMTP - Allow access to sendmail for incoming e-mail
             ${fwcmd} add pass tcp from any to any 25 setup

             # FTP - Allow incoming data channel for outgoing connections, 
             # Reject&Log all incoming control connections
             ${fwcmd} add pass tcp from any 20 to any 1024-65535 setup
             ${fwcmd} add pass log tcp from any to any 21 in via ${oif} setup

             # SSH Login - Allow & Log all incoming
             ${fwcmd} add pass log tcp from any to any 22 in via ${oif} setup

             # IDENT - Reset incoming connections 
             ${fwcmd} add reset tcp from any to any 113 in via ${oif} setup

             # Reject&Log all setup of incoming connections from the outside
             ${fwcmd} add deny log tcp from any to any in via ${oif} setup

             # Allow setup of any other TCP connection
             ${fwcmd} add pass tcp from any to any setup


             ### UDP RULES

             # DNS - Allow queries out in the world
	     #${fwcmd} add pass udp from any to any 53
	     #${fwcmd} add pass udp from any 53 to any
             ${fwcmd} add pass udp from any to ${dns1} 53
             ${fwcmd} add pass udp from any to ${dns2} 53
             ${fwcmd} add pass udp from ${dns1} 53 to any
             ${fwcmd} add pass udp from ${dns2} 53 to any

             # SMB - Allow local traffic
             ${fwcmd} add pass udp from any to any 137-139 via ${iif}

             # NTP - Allow server-to-server on outside interface, client-to-server
             # on inside interface
             ${fwcmd} add pass udp from any 123 to any 123 via ${oif}
             ${fwcmd} add pass udp from any 123 to any via ${iif}
             ${fwcmd} add pass udp from any to any 123 via ${iif}

             # TRACEROUTE - Allow outgoing, but not incoming
             ${fwcmd} add pass udp from any to any 33434-33523 out via ${oif}


             ### ICMP RULES

             # ICMP packets
             # Allow all ICMP packets on internal interface
             ${fwcmd} add pass icmp from any to any via ${iif}  

             # Allow outgoing pings, but not incoming
             ${fwcmd} add pass icmp from any to any icmptypes 8 out via ${oif}
             ${fwcmd} add pass icmp from any to any icmptypes 0 in via ${oif}           

             # Allow Destination Unreachable, Source Quench, Time Exceeded, and Bad Header
             ${fwcmd} add pass icmp from any to any icmptypes 3,4,11,12 via ${oif}

             # Deny the rest of them
             ${fwcmd} add deny icmp from any to any


             ### MISCELLANEOUS REJECT RULES

             # Reject broadcasts from outside interface
             ${fwcmd} add 63000 deny ip from any to 0.0.0.255:0.0.0.255 in via ${oif}

             # Reject&Log SMB connections on outside interface
             ${fwcmd} add 64000 deny log udp from any to any 137-139 via ${oif}

             # Reject&Log all other connections from outside interface
             ${fwcmd} add 65000 deny log ip from any to any via ${oif}

fi




--output of 'ipfw -show--

00100   0     0 divert 8668 ip from any to any via rl0
00100   0     0 allow ip from any to any via lo0
00200   0     0 deny ip from any to 127.0.0.0/8
00300   0     0 deny log logamount 100 ip from 192.168.1.0/24 to any in recv rl0
00400   0     0 deny log logamount 100 ip from 212.17.132.0/24 to any in recv xl0
00500   0     0 deny ip from 10.0.0.0/8 to any via rl0
00600   0     0 deny ip from any to 10.0.0.0/8 out xmit rl0
00700   0     0 deny ip from 172.16.0.0/12 to any via rl0
00800   0     0 deny ip from any to 172.16.0.0/12 out xmit rl0
00900   0     0 deny ip from 192.168.0.0/16 to any via rl0
01000   0     0 deny ip from any to 192.168.0.0/16 out xmit rl0
01100   0     0 deny log logamount 100 ip from 0.0.0.0/8 to any via rl0
01200   0     0 deny log logamount 100 ip from any to 0.0.0.0/8 via rl0
01300   0     0 deny log logamount 100 ip from 169.254.0.0/16 to any via rl0
01400   0     0 deny log logamount 100 ip from any to 169.254.0.0/16 via rl0
01500   0     0 deny log logamount 100 ip from 192.0.2.0/24 to any via rl0
01600   0     0 deny log logamount 100 ip from any to 192.0.2.0/24 via rl0
01700   0     0 deny log logamount 100 ip from 224.0.0.0/4 to any via rl0
01800   0     0 deny log logamount 100 ip from any to 224.0.0.0/4 via rl0
01900   0     0 deny log logamount 100 ip from 240.0.0.0/4 to any via rl0
02000   0     0 deny log logamount 100 ip from any to 240.0.0.0/4 via rl0
02100   0     0 allow tcp from any to any established
02200   0     0 allow ip from any to any frag
02300   0     0 allow tcp from any to any 80 setup
02400   0     0 allow log logamount 100 tcp from any to any 110 setup
02500   0     0 allow tcp from any to any 25 setup
02600   0     0 allow tcp from any 20 to any 1024-65535 setup
02700   0     0 allow log logamount 100 tcp from any to any 21 in recv rl0 setup
02800   0     0 allow log logamount 100 tcp from any to any 22 in recv rl0 setup
02900   0     0 reset tcp from any to any 113 in recv rl0 setup
03000   0     0 deny log logamount 100 tcp from any to any in recv rl0 setup
03100   0     0 allow tcp from any to any setup
03200   0     0 allow udp from any to 206.17.140.161 53
03300   0     0 allow udp from any to 191.164.246.5 53
03400   0     0 allow udp from 206.17.140.161 53 to any
03500   0     0 allow udp from 191.164.246.5 53 to any
03600   0     0 allow udp from any to any 137-139 via xl0
03700   0     0 allow udp from any 123 to any 123 via rl0
03800   0     0 allow udp from any 123 to any via xl0
03900   0     0 allow udp from any to any 123 via xl0
04000   0     0 allow udp from any to any 33434-33523 out xmit rl0
04100   0     0 allow icmp from any to any via xl0
04200   0     0 allow icmp from any to any out xmit rl0 icmptype 8
04300   0     0 allow icmp from any to any in recv rl0 icmptype 0
04400   0     0 allow icmp from any to any via rl0 icmptype 3,4,11,12
04500   0     0 deny icmp from any to any
63000   0     0 deny ip from any to 0.0.0.255:0.0.0.255 in recv rl0
64000   0     0 deny log logamount 100 udp from any to any 137-139 via rl0
65000   0     0 deny log logamount 100 ip from any to any via rl0
65535 357 56075 allow ip from any to any

--Boundary-=_OKWNlIDJEeNnUVlINZtiVOPgtkCI--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?00112617561277.08110>