Date: Fri, 23 Jul 2021 20:22:51 +0200 From: Michael Gmelin <freebsd@grem.de> To: Jacques Foucry <jacques+freebsd@foucry.net> Cc: Michael Gmelin <freebsd@grem.de>, freebsd-questions@freebsd.org, freebsd-jail@freebsd.org Subject: Re: iocage, vnet jail does not go outside Message-ID: <20210723202251.708ac906@bsd64.grem.de> In-Reply-To: <YPsEuaj5R6iKKHVd@mithril.foucry.net> References: <YPrwCW44LdKfHxIk@mithril.foucry.net> <20210723195142.77b668f1@bsd64.grem.de> <YPsEuaj5R6iKKHVd@mithril.foucry.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 23 Jul 2021 20:04:41 +0200 Jacques Foucry <jacques+freebsd@foucry.net> wrote: > Le vendredi 23 juil. 2021 =C3=A0 19:51:42 (+0200), Michael Gmelin =C3=A0 = =C3=A9crit: >=20 > Hello Michael, >=20 > > You need to enable some sort of NAT at your end, e.g. using pf. > > Traffic is leaving your host on a private IP. =20 >=20 >=20 > I forgot to post the part of my pf.conf your right. I enabled a NAT > (may be in a wroing way): >=20 > ext_if =3D em0 > int_if =3D "{lo0 lo1}" > bridge_if =3D bridge0 >=20 > icmp_types=3D"{ echoreq, unreach }" >=20 > # ok loopback > set skip on lo0 > set skip on lo1 > #set skip on bridge0 >=20 > # define jails > jails_net =3D "{192.168.12.0/24 10.0.10.0/24 2a01:4f9:4a:1fd8::/64}" >=20 > =E2=80=A6 >=20 > # nat > nat on $ext_if from $jails_net to any -> $ext_if >=20 > =E2=80=A6 >=20 > # ExampleJail > rdr on $ext_if inet proto tcp from any to $ext_if port > $examplejail_ports -> $examplejail_v4 rdr on $ext_if inet6 proto tcp > from any to $ext_if port $examplejail_ports -> $examplejail_v6 >=20 > =E2=80=A6 >=20 > pass in log quick on $ext_if proto tcp from any to $examplejail_v4 > port $examplejail_ports flags S/SA keep state pass in log quick on > $ext_if proto tcp from any to $examplejail_v6 port $examplejail_ports >=20 > =E2=80=A6 >=20 > # Allow icmp > pass in inet proto icmp all icmp-type $icmp_types > #IPv6 - pass in/out all IPv6 ICMP traffic > pass in quick proto icmp6 Allow >=20 >=20 >=20 > Is there something wrong of missing? I was guessing that the NAT is > correct because I can connect from outside (IPv4 and IPv6) to this > jail. >=20 >=20 > Thanks again for your time. There's one thing on your bridge that looks wrong: > bridge0: flags=3D8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 > mtu 1500 description: jails-bridge > ether 58:9c:fc:10:ed:66 > inet 10.0.10.1 netmask 0xffffff00 broadcast 10.0.10.255 > id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15 > maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200 > root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0 > member: vnet0.655 flags=3D143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP> > ifmaxaddr 0 port 6 priority 128 path cost 2000 > member: em0 flags=3D143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP> > ifmaxaddr 0 port 1 priority 128 path cost 20000 > groups: bridge > nd6 options=3D9<PERFORMNUD,IFDISABLED> > em0 shouldn't be part of the bridge, as you don't want to bridge with your uplink, but NAT to it. So try ifconfig bridge0 deletem em0 Once done, you might need to enable ip forwarding (if it isn't enabled already). service gateway enable sysctl net.inet.ip.forwarding=3D1 -m --=20 Michael Gmelin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20210723202251.708ac906>