I suppose I don't have any specific problem, it is perhaps just a bit awkward when using WiFi on laptop with different networks. i.e they assign me a random IP address and I currently have to manually edit my
/etc/rc.conf to match that with my interface device. I have a script to automatically copy across
/etc/resolv.conv but if something could be done similar for the Jail IP that would be really nice
I would suggest to create a clone of the loopback interface (
lo1 in my case), then assign a static private IP address to it (e.g. 10.0.0.1) and use NAT to connect the jail to internet. This will solve the problem of assigning the correct IP everytime.
This is what I have in
/etc/rc.conf:
Code:
cloned_interfaces="lo1"
ifconfig_lo1="inet 10.0.0.1/29"
and, since I use PF, this are the relevant parts of my
/etc/pf.conf:
Code:
# Here I refer to interface:ip-address/mask as localnet1.
localnet1=lo1:network
# If you do NOT want to filter your LOCAL jail traffic, tell PF to skip your cloned interface.
set skip on lo1
# This rule will tell to PF to NAT $localnet1 to the actual defined external interface.
# In case you have more than one, and want to refer to the actual used, use (egress).
nat on $ext_if inet from $localnet1 to any -> ($ext_if)
# This will serve you if you WANT to filter your LOCAL traffic on lo1.
# Your TCP traffic.
pass quick on lo1 inet proto tcp from 10.0.0.1 to 10.0.0.1 port { <your list of ports> }
# Settings for DNS.
pass quick on lo1 inet proto udp from 10.0.0.1 to 10.0.0.1 port { 53 }
About
/etc/resolv.conf instead, I guess that you use DHCP and your DNS settings are overwritten everytime, right? In this case you can tell
dhclient to stick with your DNS servers of choice; simply add this to your
/etc/dhclient.conf:
Code:
prepend domain-name-servers $ip1,$ip2 ;
How do you forward out the graphics? Do you also use something like Xvnc or X11 forwarding?
I use X11 forwarding, never used Xvnc. Exists
sysutils/jailme that let unprivileged users to run programs inside jails, but you should make Xorg listen for TCP connections (personally I don't like this solution).
EDIT: If you don't want/cannot rely on NAT, and want to automate the IP address change in
/etc/rc.conf, you can set
exec.prestart = "<command to run>";
in
/etc/jail.conf, where <command to run> can be a shell script to change the IP address with, in example,
sed -i "" 's/$old_ip/$new_ip/' /etc/rc.conf
. In this way the OS will run your script before starting the jail. Refer to
jail(8) for other parameters accepted in
/etc/jail.conf.
HTH