From owner-freebsd-questions Thu Feb 8 21:55:22 2001 Delivered-To: freebsd-questions@freebsd.org Received: from hnet04.kellyhendrix.com (unknown [208.233.247.37]) by hub.freebsd.org (Postfix) with ESMTP id 51C2737B401 for ; Thu, 8 Feb 2001 21:55:00 -0800 (PST) Received: by hnet04.kellyhendrix.com (Postfix, from userid 1001) id 2B91018C8B; Fri, 9 Feb 2001 00:55:27 -0500 (EST) Date: Fri, 9 Feb 2001 00:55:27 -0500 From: Kelly Hendrix To: FreeBSD Questions Subject: Redirect port to internal address Message-ID: <20010209005527.E8297@hnet04.kellyhendrix.com> Reply-To: Kelly Hendrix Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i X-Freebsd-Version: FreeBSD 4.2-STABLE i386 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Greetings, I'm trying to redirect all incoming traffic on port 80 of my external ip to an address on my internal lan, same port. This is what I have in my /etc/natd.conf on my firewall/lan box: use_sockets yes same_ports yes unregistered_only yes redirect_port tcp 192.168.0.4:80 80 Here are the relevant items in rc.conf: firewall_enable="YES" firewall_script="/root/rc.firewall" firewall_quiet="NO" natd_program="/sbin/natd" natd_enable="YES" natd_interface="dc0" natd_flags="-f /etc/natd.conf" Yes, I know my rc.firewall is in a nonstandard place. Basically, it's just a set of rules, similar to client without all the tests for firewall type, hence no need to declare a specific type in rc.conf. My guess is that it's my firewall rules causing the redirect problems here. A couple of things I've tried. From my /root/rc.firewall: ${fwcmd} add pass tcp from any to any 80 setup ${fwcmd} add divert natd all from any to any via dc0 When I do this, none of my internal browsers work. No go on redirection either. And when I do this: ${fwcmd} add divert natd all from any to any via dc0 ${fwcmd} add pass tcp from any to any 80 setup my browsers work, but again, no redirection. I will post my complete firewall rules at the end, in case someone needs to look at them. Also, the server is in place and working because when I go to my other machines and type in the IP, I get the generic apache screen. Can anyone give me any suggestions on how to make this work? TIA. Kelly Hendrix My complete /root/rc.firewall: #fwcmd="/sbin/ipfw -q" fwcmd="/sbin/ipfw" ${fwcmd} -f flush ${fwcmd} add 100 pass all from any to any via lo0 ${fwcmd} add 200 deny all from any to 127.0.0.0/8 oif="dc0" onet="208.233.247.37" omask="255.255.255.255" oip="208.233.247.37" iif="dc1" inet="192.168.0.0" 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 any to 10.0.0.0/8 via ${oif} ${fwcmd} add deny all from any to 172.16.0.0/12 via ${oif} ${fwcmd} add deny all from any to 192.168.0.0/16 via ${oif} # Stop draft-manning-dsua-03.txt (1 May 2000) nets (includes RESERVED-1, # DHCP auto-configuration, NET-TEST, MULTICAST (class D), and class E) # on the outside interface ${fwcmd} add deny all from any to 0.0.0.0/8 via ${oif} ${fwcmd} add deny all from any to 169.254.0.0/16 via ${oif} ${fwcmd} add deny all from any to 192.0.2.0/24 via ${oif} ${fwcmd} add deny all from any to 224.0.0.0/4 via ${oif} ${fwcmd} add deny all from any to 240.0.0.0/4 via ${oif} #${fwcmd} add pass tcp from any to any 80 setup # Network Address Translation. This rule is placed here deliberately # so that it does not interfere with the surrounding address-checking # rules. If for example one of your internal LAN machines had its IP # address set to 192.0.2.1 then an incoming packet for it after being # translated by natd(8) would match the `deny' rule above. Similarly # an outgoing packet originated from it before being translated would # match the `deny' rule below. ${fwcmd} add divert natd all from any to any via dc0 #Allow all traffic on internal network ${fwcmd} add allow all from ${inet}:${imask} to ${inet}:${imask} #Shutdown NetBIOS to outside world ${fwcmd} add deny log tcp from any 137-139 to any out via dc0 ${fwcmd} add deny log udp from any 137-139 to any out via dc0 ${fwcmd} add deny log tcp from any to any 137-139 in via dc0 ${fwcmd} add deny log udp from any to any 137-139 in via dc0 #Shutdown rpc.stat and mountd to outside interface ${fwcmd} add deny log tcp from any to any 1022-1023 via dc0 ${fwcmd} add deny log udp from any to any 1022-1023 via dc0 ${fwcmd} add deny log tcp from any 1022-1023 to any via dc0 ${fwcmd} add deny log udp from any 1022-1023 to any via dc0 #abbaccuray? Port being probed ${fwcmd} add deny log tcp from any to any 1546 via dc0 ${fwcmd} add deny log udp from any to any 1546 via dc0 ${fwcmd} add deny log tcp from any 1546 to any via dc0 ${fwcmd} add deny log udp from any 1546 to any via dc0 #Shutdown Xserver to outside interface ${fwcmd} add deny log tcp from any to any 6000 via dc0 ${fwcmd} add deny log udp from any to any 6000 via dc0 ${fwcmd} add deny log tcp from any 6000 to any via dc0 ${fwcmd} add deny log udp from any 6000 to any via dc0 #Shutdown nfs to outside interface ${fwcmd} add deny log tcp from any to any 2049 via dc0 ${fwcmd} add deny log udp from any to any 2049 via dc0 ${fwcmd} add deny log tcp from any 2049 to any via dc0 ${fwcmd} add deny log udp from any 2049 to any via dc0 #Shutdown portmap to outside interface ${fwcmd} add deny log tcp from any to any 111 via dc0 ${fwcmd} add deny log udp from any to any 111 via dc0 ${fwcmd} add deny log tcp from any 111 to any via dc0 ${fwcmd} add deny log udp from any 111 to any via dc0 # 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 172.16.0.0/12 to any via ${oif} ${fwcmd} add deny all from 192.168.0.0/16 to any via ${oif} # Stop draft-manning-dsua-03.txt (1 May 2000) nets (includes RESERVED-1, # DHCP auto-configuration, NET-TEST, MULTICAST (class D), and class E) # on the outside interface ${fwcmd} add deny all from 0.0.0.0/8 to any via ${oif} ${fwcmd} add deny all from 169.254.0.0/16 to any via ${oif} ${fwcmd} add deny all from 192.0.2.0/24 to any via ${oif} ${fwcmd} add deny all from 224.0.0.0/4 to any via ${oif} ${fwcmd} add deny all from 240.0.0.0/4 to any 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 setup of incoming email ${fwcmd} add pass tcp from any to any 25 setup # Allow access to our DNS #${fwcmd} add pass tcp from any to ${oip} 53 setup #${fwcmd} add pass udp from any to ${oip} 53 #${fwcmd} add pass udp from ${oip} 53 to any # Allow access to our WWW ${fwcmd} add pass tcp from any to any 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 any ${fwcmd} add pass udp from any 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 #Allow all icmp traffic on the inner interface ${fwcmd} add pass icmp from any to any via ${iif} # Allow pings ${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 some other icmp traffic including traceroute ${fwcmd} add pass icmp from any to any icmptypes 3,4,11,12 via ${oif} #Disallow what's left ${fwcmd} add deny icmp from any to any To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message