Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Feb 2000 21:18:41 -0800
From:      chip <chip@wiegand.org>
To:        keramida@ceid.upatras.gr
Cc:        questions@freebsd.org
Subject:   Re: rc.firewall problem - Take 4
Message-ID:  <38A39BB1.17ED9740@wiegand.org>
References:  <20000208040302.B10648@hades.hell.gr> <00020800084901.02763@firewall.homenet> <20000210162740.A13143@hades.hell.gr>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------EF1CA0816D548B6D5DF63F93
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Thanks for the suggestion of using ifpw show, I didn't know that command.
I have attached two files - the results of running ipfw show as a text doc
and
my rc.firewall file.
I hope these are readable. I thought it would be better to attach them
than
to copy the whole text into the message.
Chip W


Giorgos Keramidas wrote:

> On Mon, Feb 07, 2000 at 11:39:33PM -0800, Chip wrote:
> >
> > I still have a problem though. When I try to ping another machine on
> > my network I get the following message:
> >
> >       ping: sendto: Permission denied
> >
> > I can ping the nics in that machine though. I believe this may be
> > because icmp is blocked by the firewall?
>
> Without the actual rules, as printed by `ipfw show' there isn't much I
> can guess about why ping fails to work.  Blocked icmp's could be a
> reason, though.
>
> --
> Giorgos Keramidas, < keramida @ ceid . upatras . gr >
> For my public PGP key: finger keramida@diogenis.ceid.upatras.gr
> PGP fingerprint, phone and address in the headers of this message.

--------------EF1CA0816D548B6D5DF63F93
Content-Type: text/plain; charset=us-ascii;
 name="rc.firewall"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="rc.firewall"

############
# 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
elif [ -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" -a "X${natd_interface}" != X"" ]; 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.0.1"
    mask="255.255.255.0"
    ip="192.168.0.1"

    # 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

    ############
    # This is a prototype setup for a simple firewall.  Configure this machine 
    # as a named server and ntp server, and point all the machines on the inside
    # at this machine for those services.
    ############

    # set these to your outside interface network and netmask and ip
    oif="mx0"
    onet="208.194.173.26"
    omask="255.255.255.128"
    oip="208.194.173.26"

    # set these to your inside interface network and netmask and ip
    iif="pn0"
    inet="192.168.0.1"
    imask="255.255.255.0"
    iip="192.168.0.1"

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

    # Stop RFC1918 nets on the outside interface
    $fwcmd add deny all from 192.168.0.0:255.255.0.0 to any via ${oif}
    $fwcmd add deny all from any to 192.168.0.0:255.255.0.0 via ${oif}
    $fwcmd add deny all from 172.16.0.0:255.240.0.0 to any via ${oif}
    $fwcmd add deny all from any to 172.16.0.0:255.240.0.0 via ${oif}
    $fwcmd add deny all from 10.0.0.0:255.0.0.0 to any via ${oif}
    $fwcmd add deny all from any to 10.0.0.0:255.0.0.0 via ${oif}

    # 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 ${oip} 25 setup

    # Allow access to our DNS
    $fwcmd add pass tcp from any to ${oip} 53 setup

    # Allow access to our WWW
    $fwcmd add pass tcp from any to ${oip} 80 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

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

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

    # Everything else is denied as default.

elif [ "${firewall_type}" != "UNKNOWN" -a -r "${firewall_type}" ]; then
	$fwcmd ${firewall_type}
fi

--------------EF1CA0816D548B6D5DF63F93
Content-Type: text/plain; charset=us-ascii;
 name="ipfw_show.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="ipfw_show.txt"

chip# ipfw show
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 ip from 192.168.0.0/24 to any in recv mx0
00400  0    0 deny ip from 208.194.173.0/25 to any in recv pn0
00500 30 7265 deny ip from 192.168.0.0/16 to any via mx0
00600  0    0 deny ip from any to 192.168.0.0/16 via mx0
00700  0    0 deny ip from 172.16.0.0/12 to any via mx0
00800  0    0 deny ip from any to 172.16.0.0/12 via mx0
00900  0    0 deny ip from 10.0.0.0/8 to any via mx0
01000  0    0 deny ip from any to 10.0.0.0/8 via mx0
01100 23 7274 allow tcp from any to any established
01200  0    0 allow tcp from any to 208.194.173.26 25 setup
01300  0    0 allow tcp from any to 208.194.173.26 53 setup
01400  0    0 allow tcp from any to 208.194.173.26 80 setup
01500  0    0 deny log logamount 100 tcp from any to any in recv mx0 setup
01600  8  384 allow tcp from any to any setup
01700  0    0 allow udp from any 53 to 208.194.173.26
01800  0    0 allow udp from 208.194.173.26 to any 53
01900  0    0 allow udp from any 123 to 208.194.173.26
02000  0    0 allow udp from 208.194.173.26 to any 123
65535 36 2634 deny ip from any to any  

--------------EF1CA0816D548B6D5DF63F93--



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?38A39BB1.17ED9740>