Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Mar 2003 12:43:52 +1100
From:      Carey Nairn <Carey.Nairn@dpac.tas.gov.au>
To:        freebsd-ipfw@freebsd.org
Subject:   IPFW and ntpd
Message-ID:  <5.1.0.14.0.20030329123307.040e9880@mail.cpn.homeip.net>

next in thread | raw e-mail | index | archive | help
I am having a problem with getting ntpd to work with ipfw.  Using my simple 
firewall setup (based on the default /etc/rc.firewall), I get the following 
error when I start ntpd:

ntpd_initres[23825]: send to NTP server failed: Permission denied

If I set my firewall to OPEN, ntpd works just fine.

My firewall configuration is executed whenever my PPP (ADSL) connection is 
established and is as follows:

#!/bin/sh

fwcmd="/sbin/ipfw"

${fwcmd} -f flush

oif="tun0"
oip=`/sbin/ifconfig tun0 | grep -v grep | grep "inet " | awk '{ print $2 }'`
onet=$oip
omask="255.0.0.0"

iif="fxp0"
inet="172.16.1.0"
imask="255.255.255.0"
iip="172.16.1.4"

${fwcmd} add pass all from ${iip} to ${inet}:${imask}
${fwcmd} add pass all from ${inet}:${imask} to ${iip}

# Deny incoming ICMP requests
${fwcmd} add deny log icmp from any to any in via ${oif} icmptypes 8

# Allow outgoing ICMP requests
${fwcmd} add pass icmp from any to any out via ${oif} icmptypes 8
${fwcmd} add pass icmp from any to any in via ${oif} icmptypes 0

# 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 draft-manning-dsua-01.txt nets on the outside interface
${fwcmd} add deny all from 0.0.0.0/8 to any via ${oif}
${fwcmd} add deny all from any to 0.0.0.0/8 via ${oif}
${fwcmd} add deny all from 169.254.0.0/16 to any via ${oif}
${fwcmd} add deny all from any to 169.254.0.0/16 via ${oif}
${fwcmd} add deny all from 192.0.2.0/24 to any via ${oif}
${fwcmd} add deny all from any to 192.0.2.0/24 via ${oif}
${fwcmd} add deny all from 224.0.0.0/4 to any via ${oif}
${fwcmd} add deny all from any to 224.0.0.0/4 via ${oif}
${fwcmd} add deny all from 240.0.0.0/4 to any via ${oif}
${fwcmd} add deny all from any to 240.0.0.0/4 via ${oif}

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

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

# Allow access to ssh
${fwcmd} add pass tcp from any to ${oip} 22 setup
${fwcmd} add pass tcp from any to ${oip} 22

# Allow setup of incoming email
${fwcmd} add pass tcp from any to ${oip} 25 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 ${oip} to any 123 keep-state

any thoughts on why the ntp rule fails?

thanks
Carey Nairn



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