Date: Sun, 4 Sep 2016 16:43:20 +0000 From: James Lodge <James@Lodge.me.uk> To: Grzegorz Junka <list1@gjunka.com> Cc: "freebsd-jail@freebsd.org" <freebsd-jail@freebsd.org> Subject: Re: Changing jail's IP automatically Message-ID: <761D111F-F968-477B-9247-DABD205CEE1C@Lodge.me.uk> In-Reply-To: <9fd404a3-f1cc-4510-1d38-5ca8dc85f5d3@gjunka.com> References: <872dfbe1-3f39-bf5f-44b2-611bd92a1210@gjunka.com> <4fa37d2e14665ff5a00548626e55142f@gritton.org> <F9734DA1-D3BE-46C8-87C7-91C4C4B653F1@Lodge.me.uk>, <9fd404a3-f1cc-4510-1d38-5ca8dc85f5d3@gjunka.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> On 4 Sep 2016, at 17:32, Grzegorz Junka <list1@gjunka.com> wrote: >=20 > Probably it would, I didn't try. Is this is the proper way of solving thi= s issue? >=20 >=20 >> On 03/09/2016 15:49, James Lodge wrote: >> Would PF and NAT not work for you? NAT to the WLAN0 IP (DHCP assigned) u= sing PF macros and have a separate subnet for your jails? This would be PAT= so you might have issues with accessing services inbound if you're using t= he same port in multiple jails. Just an idea..... >>=20 >> Sent from my iPad >>=20 >>>> On 3 Sep 2016, at 16:33, James Gritton <jamie@freebsd.org> wrote: >>>>=20 >>>> On 2016-09-02 15:08, Grzegorz Junka wrote: >>>> I am using a jail on my laptop and I often connect to different >>>> WiFi's, which of course assign different IPs to my laptop. I set up >>>> the jail by adding an alias to wlan0 and I need to update the IP every >>>> time I switch the WiFi network. Is it possible to create a jail with >>>> IP assigned dynamically, e.g. from DHCP, or at least switch between >>>> predefined IPs more easily than by editing /etc/jail.conf? >>> You can always add addresses later. I would create the jail without an= y IP address specified in jail.conf, and then have a exec.poststart script = that sets the address using something like "jail -m name=3Dfoo ip4.addr=3D1= .2.3.4". And similarly when the network switches, it would need to trigger= a similar script that resets the address. >>>=20 >>> It's a little more complicated that than though: network daemons will b= e bound to the old address after the switch, so you'll need to run the prop= er service(8) commands to restart those, in the right order. Or depending = on the service, maybe a kick of some sort (like a kill -1) would do the tri= ck. >>>=20 >>> And at start time, if the jail has no IP address of its own, anything i= t runs will use the regular system IP addresses. That's definitely not wha= t you want. Unfortunately, jail(8) doesn't have a way to run a script in t= he system environment after the jail is created but before exec.start is ru= n. That would be the right place to set the initial address. So barring t= hat, you may want to have network services not started up at all, until thi= s poststart script sets the address. So it's still not a simple issue. >>>=20 >>> - Jamie >>> _______________________________________________ >>> freebsd-jail@freebsd.org mailing list >>> https://lists.freebsd.org/mailman/listinfo/freebsd-jail >>> To unsubscribe, send any mail to "freebsd-jail-unsubscribe@freebsd.org" >=20 > _______________________________________________ > freebsd-jail@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-jail > To unsubscribe, send any mail to "freebsd-jail-unsubscribe@freebsd.org" There are many way to handle it, using NAT would be the easiest and the way= products like VirtualBox and VMware workstation handles it's on a desktop/= laptop.=20
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?761D111F-F968-477B-9247-DABD205CEE1C>