I have been running the PB-BSD 8.2 and switching between work and home networks.
I have figured out that I have to run these commands when I want to switch over to use wireless:
|sudo wpa_cli reassociate
sudo route flush
When switching back to Ethernet, I have use these two commands:
|sudo route flush
sudo dhclient em0
I thought I was done listing the commands that must be run, until I realized that the above commands didn’t change the /etc/resolv.conf in my Ports Jail.
Question: What network settings need updating in the Ports Jail.
Answer: The Ports Jail uses the systems IP Address and Default Route, so only the /etc/resolv.conf needs updated and it appears to be a copy of the system’s /etc/resolv.conf
So I just have to update /etc/resolv.conf and that is all.
Well, one solution is to run another command that just copies the system’s /etc/resolv.conf to the Port Jail.
But a better solution is to get dhclient to run this command for us. This can be done with the dhclient-exit-hooks.
Step 1 – Create the dhclient-exit-hooks file and make it executable
|sudo touch /etc/dhclient-exit-hooks
chmod +x /etc/dhclient-exit-hooks
Step 2 – Enter the function into the /etc/dhclient-exit-hooks to run copy command when dhclient exists
#!/bin/sh cp /etc/resolv.conf /usr/jails/portjail/etc/resolv.conf
Now when you run dhclient, you will also get a new /etc/resolv.conf in your Ports Jail.