From owner-freebsd-pf@freebsd.org Thu May 26 12:29:09 2016 Return-Path: Delivered-To: freebsd-pf@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0EA15B4993E for ; Thu, 26 May 2016 12:29:09 +0000 (UTC) (envelope-from maximos@als.nnov.ru) Received: from mx.als.nnov.ru (mx.als.nnov.ru [95.79.102.161]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C6047181A for ; Thu, 26 May 2016 12:29:08 +0000 (UTC) (envelope-from maximos@als.nnov.ru) Received: from [10.4.1.100] by mx.als.nnov.ru with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.86_2 (FreeBSD)) (envelope-from ) id 1b5uPJ-000HL6-Ed for freebsd-pf@freebsd.org; Thu, 26 May 2016 15:28:57 +0300 Subject: Re: `echo | pfctl -mf -` overriding instead of modifying To: freebsd-pf@freebsd.org References: <20160518072409.GD99839@box-fra-01.niklaas.eu> <20160526114645.GB49239@box-fra-01.niklaas.eu> From: Max Message-ID: Date: Thu, 26 May 2016 15:28:57 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <20160526114645.GB49239@box-fra-01.niklaas.eu> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-pf@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Technical discussion and general questions about packet filter \(pf\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 May 2016 12:29:09 -0000 Hello, Niklaas. Can you try something like exec.poststart = "/bin/sh /path/to/pf-config.sh $name $private_ip4 $private_ip6" where pf-config.sh contains #!/bin/sh echo "rdr pass on vtnet0 inet proto { udp tcp } to vtnet0 port domain -> $2 rdr pass on vtnet0 inet6 proto { udp tcp } to vtnet0 port domain -> $3" | pfctl -a "jails/$1" -Nf - 26.05.2016 14:46, Niklaas Baudet von Gersdorff пишет: > Niklaas Baudet von Gersdorff [2016-05-18 09:24 +0200] : > > [...] >> Initially, I only used the `-f -` flags for pfctl (instead of `-mf -`) and >> realised that making changes to the anchor overrides existing rules. So >> I read pfctl(8) where it says >> >> -m Merge in explicitly given options without resetting those >> which are omitted. Allows single options to be modified without >> disturbing the others: >> >> # echo "set loginterface fxp0" | pfctl -mf - >> >> So I thought that adding `-m` to the rule in the second `exec.poststart` >> will include (instead of replace) the rules into the anchor. But this is >> not the case. What am I doing wrong? Do I misunderstand `-m`? > I clearly misunderstood -m. It says that it merges "given *options* > without resetting those which are omitted" i.e., options and not rules. > No wonder that it's not working. > > I will recheck pfctl(8) but I assume that there is no other way than > inserting the rules in questions in a one-liner -- or using different > anchors like jails/$name-ipv4 and jails/$name-ipv6. > > Niklaas