From owner-freebsd-questions@freebsd.org Tue Apr 11 12:38:07 2017 Return-Path: Delivered-To: freebsd-questions@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 98493D39D09 for ; Tue, 11 Apr 2017 12:38:07 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from sola.nimnet.asn.au (paqi.nimnet.asn.au [115.70.110.159]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 18934C62 for ; Tue, 11 Apr 2017 12:38:06 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from localhost (localhost [127.0.0.1]) by sola.nimnet.asn.au (8.14.2/8.14.2) with ESMTP id v3BCbsYS053706; Tue, 11 Apr 2017 22:37:54 +1000 (EST) (envelope-from smithi@nimnet.asn.au) Date: Tue, 11 Apr 2017 22:37:54 +1000 (EST) From: Ian Smith To: Polytropon cc: Miha Smrekar , freebsd-questions@freebsd.org Subject: Re: FreeBSD firewall configuration In-Reply-To: <20170411220239.S9330@sola.nimnet.asn.au> Message-ID: <20170411223428.O9330@sola.nimnet.asn.au> References: <20170411220239.S9330@sola.nimnet.asn.au> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Apr 2017 12:38:07 -0000 On Tue, 11 Apr 2017 22:25:03 +1000, Ian Smith wrote: > In freebsd-questions Digest, Vol 671, Issue 2, Message: 3 > On Mon, 10 Apr 2017 21:37:47 +0200 Polytropon wrote: > > > > Can you also help me with the rule to forward incoming trafic to other > > > interface? > > > > You first need to put > > > > net.inet.ip.forwarding=1 > > > > into /etc/sysctl.conf and make this change active (read: reboot or > > Reboot? Like Windows? :) > > > manually call "service sysctl restart". > > > > Additionally, add > > > > gateway_enable="YES" > > > > to /etc/rc.conf. > > Just a minor niggle .. having gateway_enable="YES" in rc.conf causes > net.inet.ip.forwarding=1 to be set by /etc/rc.d/routing, so you don't > need to add it to /etc/sysctl.conf as well - though it won't hurt, > unless you later wanted to turn it off by updating rc.conf :) Actually, on a further check that I should have done before posting: smithi@x200:~ % rcorder /etc/rc.d/* | egrep 'sysctl|routing' /etc/rc.d/sysctl /etc/rc.d/routing So the rc.conf setting will override sysctl.conf anyway. Still .. > Then just a 'service routing restart' will do the trick. From which: > > if checkyesno gateway_enable; then > ropts_init inet > echo -n ' gateway=YES' > ${SYSCTL} net.inet.ip.forwarding=1 > /dev/null > else > ${SYSCTL} net.inet.ip.forwarding=0 > /dev/null > fi > > cheers, Ian