From nobody@FreeBSD.org  Wed Aug 22 15:23:51 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 422E916A417
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 22 Aug 2007 15:23:51 +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 2F7CA13C48E
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 22 Aug 2007 15:23:51 +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 l7MFNosA074986
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 22 Aug 2007 15:23:51 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.1/8.14.1/Submit) id l7MFNoMj074985;
	Wed, 22 Aug 2007 15:23:50 GMT
	(envelope-from nobody)
Message-Id: <200708221523.l7MFNoMj074985@www.freebsd.org>
Date: Wed, 22 Aug 2007 15:23:50 GMT
From: Eric Kjeldergaard <kjelderg@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: pf nat -> ($if) works only intermittently
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         115725
>Category:       kern
>Synopsis:       pf nat -> ($if) works only intermittently
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-pf
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 22 15:30:01 GMT 2007
>Closed-Date:    Wed Aug 22 22:11:14 GMT 2007
>Last-Modified:  Wed Aug 22 22:11:14 GMT 2007
>Originator:     Eric Kjeldergaard
>Release:        6.2-RELEASE
>Organization:
>Environment:
FreeBSD fluffy.dname.net 6.2-RELEASE FreeBSD 6.2-RELEASE #3: Fri May  4 11:22:03 CDT 2007 root@fluffy.dname.net:/usr/obj/usr/src/sys/FLUFFY  i386
>Description:
rc.conf network configuration and jail configuration:

# network setup
ifconfig_re0="inet 10.1.1.9 netmask 255.255.255.0 media 100baseTX mediaopt full-duplex"
defaultrouter="10.1.1.1"
 
# FreeNX Jail setup
jail_freenx_rootdir="/jails/FreeNXJail"
jail_freenx_hostname="freenx.fluffy.dname.net"
jail_freenx_interface="re0"
jail_freenx_ip="192.168.1.2"
jail_freenx_procfs_enable="YES"
jail_freenx_devfs_enable="YES"
jail_freenx_devfs_ruleset="devfsrules_jail"
jail_freenx_mount_enable="NO"

pf rules:
ext_if="re0"
freenx_jail_ip="192.168.1.2"
nat pass on $ext_if from $freenx_jail_ip to any -> ($ext_if)

When I then jexec a shell in the jail and try to do things on the network, only 1 in 3 or so connections would work.  Ideally they should have all worked.  My solution follows, but it is a workaround for the bug.
>How-To-Repeat:
set up a jail as described and a pf conf as described.  Try to access the network, it will fail most of the time by timing out.
>Fix:
This goes into pf.conf instead of what was shown above.

ext_ip="10.1.1.9"
nat pass on $ext_if from $freenx_jail_ip to any -> $ext_ip

Now the networking works flawlessly.  Unfortunately, this also limits my ability to change my external ip freely.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-pf 
Responsible-Changed-By: remko 
Responsible-Changed-When: Wed Aug 22 15:32:08 UTC 2007 
Responsible-Changed-Why:  
Redirect to the PF team 

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

From: Max Laier <max@love2party.net>
To: bug-followup@freebsd.org,
 kjelderg@gmail.com
Cc:  
Subject: Re: kern/115725: pf nat -&gt; ($if) works only intermittently
Date: Wed, 22 Aug 2007 23:44:39 +0200

 > nat pass on $ext_if from $freenx_jail_ip to any -> ($ext_if)
 >
 > When I then jexec a shell in the jail and try to do things on the
 > network, only 1 in 3 or so connections would work. Ideally they should
 > have all worked.
 
 This usually happens when you have aliases on $ext_if.  In this case 
 ($ext_if) expands to a round-robin pool with all addresses assigned to 
 the interface.  If you want to use the primary address on that interface 
 you can use the "($ext_if:0)" syntax to exclude aliases.  If the address 
 you want to use is an alias, you have to specify it manually.
 
 --
   Max
State-Changed-From-To: open->closed 
State-Changed-By: mlaier 
State-Changed-When: Wed Aug 22 22:10:23 UTC 2007 
State-Changed-Why:  
Sollution confirmed by submitter.  Thanks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=115725 
>Unformatted:
