From nobody@FreeBSD.org  Sun Sep  9 22:08:49 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 7ECCB16A49A
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  9 Sep 2007 22:08:49 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 587AB13C465
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  9 Sep 2007 22:08:49 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.1/8.14.1) with ESMTP id l89M8n7Q045888
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 9 Sep 2007 22:08:49 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.1/8.14.1/Submit) id l89M8nXn045887;
	Sun, 9 Sep 2007 22:08:49 GMT
	(envelope-from nobody)
Message-Id: <200709092208.l89M8nXn045887@www.freebsd.org>
Date: Sun, 9 Sep 2007 22:08:49 GMT
From: Joe Acosta <josepha48@yahoo.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: natd/ipfw not maintaining interface of udp packets (maybe tcp too?)
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         116238
>Category:       misc
>Synopsis:       natd/ipfw not maintaining interface of udp packets (maybe tcp too?)
>Confidential:   no
>Severity:       non-critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 09 22:10:04 GMT 2007
>Closed-Date:    Mon Sep 10 07:20:50 GMT 2007
>Last-Modified:  Mon Sep 10 16:30:04 GMT 2007
>Originator:     Joe Acosta
>Release:        6.2 p7
>Organization:
>Environment:
FreeBSD gaywayrouter.org 6.2-RELEASE-p7 FreeBSD 6.2-RELEASE-p7 #3: Thu Aug 16 21:54:24 PDT 2007     root@bobthebuilder.gaywayrouter.org:/usr/obj/usr/src/sys/CDGAYWAY  i386

>Description:
natd is natting everything and messing up certain outgoing packets.

So packets coming in on interface INT_IFACE go out EXT_IFACE and come back again.  That works fine as expected. 

However running a service on the internal interface (INT_IFACE) results in packets going into INT_IFACE and returing from EXT_IFACE.  This was first noticed in isc-dhcp3-server where the service is not bound to an ip address, it is bound to an interface like INT_IFACE.  


For DNS queries go out EXT_IFACE with EXT_IP address. Then they come back in and are 'de-natted' and sent to INT_IFACE.  

DNS: 

    - query comes in via int iface / ilan
    - query then is natted and sent out ext iface / ext ip 
    - query comes back in via ext iface and denatted 
    - response is sent back to client in iface / ilan


For DHCP packets are sent broadcast.  

    - query comes in via int iface / ilan as broadcast 0.0.0.0 68 to 255.255.255.255 67
    - query then is natted and sent out ext iface / ext ip 
         ----> broadcast OUT Ext interface instead of int iface 
    - client never gets IP address.


Could it be my firewall rules or something else?  yes, but this setup works with a dhcp binary built with freebsd 5.x


>How-To-Repeat:
install dhcp, on a dual nic box. 

setup a firewall and nat on ext nic using ipfw/natd

try to get dhcp ip address on internal lan


>Fix:


>Release-Note:
>Audit-Trail:

From: "Andrey V. Elsukov" <bu7cher@yandex.ru>
To: Joe Acosta <josepha48@yahoo.com>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: misc/116238: natd/ipfw not maintaining interface of udp packets
        (maybe tcp too?)
Date: Mon, 10 Sep 2007 10:53:53 +0400

 Joe Acosta wrote:
 >> Description:
 > natd is natting everything and messing up certain outgoing packets.
 
 No. natd is natting only packets wich it gets from the divert socket.
 You should make *correct* "ipfw divert" rules.
 
 >> How-To-Repeat:
 > install dhcp, on a dual nic box. 
 > setup a firewall and nat on ext nic using ipfw/natd
 > try to get dhcp ip address on internal lan
 
 Why you pass DHCP packets into divert socket? Don't do it.
 
 -- 
 WBR, Andrey V. Elsukov
State-Changed-From-To: open->closed 
State-Changed-By: remko 
State-Changed-When: Mon Sep 10 07:20:49 UTC 2007 
State-Changed-Why:  
This does not sound like a application bug, but a user bug ;-). Please 
use correct rules to nat your traffic etc. For information on how to do 
that see the examples in the handbook, manual pages and/or on the 
freebsd-ipfw list (ipfw@). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=116238 

From: Joe <josepha48@yahoo.com>
To: "bug-followup@FreeBSD.org" <bug-followup@FreeBSD.org>,
  "josepha48@yahoo.com" <josepha48@yahoo.com>
Cc:  
Subject: Re: misc/116238: natd/ipfw not maintaining interface of udp packets (maybe tcp too?)
Date: Mon, 10 Sep 2007 08:53:15 -0700 (PDT)

 Funny that you mention the &#39;divert rules&#39;.  I have firewall rules t=
 hat have been in use since about 4.2 and worked fine when I upgraded my old=
  4.2 box up to 5.x and 6.x and all the way up to 6.2 p6.  I have a new box =
 that I installed fresh with 6.2 p7 and the old dhcpd binary that was built =
 prior to this, works fine with my firewall rules.  The new dhcpd binary bui=
 lt with 6.2 p7 which uses the same config as the old one and is the same ve=
 rsion ( binaries differ though ) gets a packet in on INT_IFACE and then the=
  reply gets broadcast out EXT_IFACE.  I am using the divert rule on the EXT=
 _IFACE ONLY! =20
 
 If my rules are wrong, why have they worked for so long, then just suddenly=
  broke with a new install?=0A=0A=0A       =0A______________________________=
 ______________________________________________________=0ATake the Internet =
 to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more=
 . =0Ahttp://mobile.yahoo.com/go?refer=3D1GNXIC
>Unformatted:
