Running a command when a specific interface is created or destroyed

Rolf Nielsen rmg1970swe at
Thu May 1 11:07:21 UTC 2014

Hash: SHA1

On 2014-04-24 19:13, Julian H. Stacey wrote:
> Warren Block wrote:
>> On Thu, 24 Apr 2014, Rolf Nielsen wrote:
>>> Hi,
>>> I use my phone's 3G/4G connection to connect my computer to
>>> the internet. With the help of the urndis driver, it comes up
>>> as ue0. However, if I reboot the computer, the phone
>>> automatically disables USB tethering, and I can't re-enable it
>>> until the boot is complete.
>>> Being somewhat paranoid, I use an OpenVPN service, and I want
>>> the cilent to start automatically. I obviously can't set it to
>>> start from rc.conf, as I can't log in to the server before I
>>> have an internet connection.
>>> So, is there a way to start the OpenVPN client automatically
>>> upon creation of the ue0 interface? E.g. can dhclient be set up
>>> to run the openvpn start script after it has given ue0 an IP
>>> address? And is there a way to automatically stop the openvpn
>>> client if ue0 is destroyed, e.g. if I disconnect my phone from
>>> the computer?
>> devd(8) can do that.  Look at /etc/devd.conf for some examples,
>> and devd.conf(5) for more detail.
> Yes, devd & its conf are very useful.
>>> So, is there a way to start the OpenVPN client automatically
>>> upon creation of the ue0 interface?
> Yes, Example: I automatically fetch a password (if environment is 
> secure) to gbde decrypt & mount a UFS when a USB stick is
> attached. 
See lines beginning: gbde attach
> On detach, closing processes or unmounting file systems Before a 
> device disappears is more problematic, as devd only gets nudged
> after. I suppose if a VPN has a watchdog/ keepalive, no problem. 
> (For my crypted UFS, I should config AMD to umount my /media/* on 
> timeout, [& remount on demand]).
> Cheers, Julian

Thanks and sorry for not giving feedback sooner; I've been busy with
other things.

I didn't get devd working. No matter what I put in devd.conf, it
wouldn't react when I attached my phone. I fiddled with it for I don't
know how long.

However, I still solved the problem. I got a new SIM card and have
dedicated my old phone, a Galaxy S3, to this, so I never have to
disconnect the phone from the computer. Moreover, the S3 doesn't
disable the USB tethering when I reboot the computer, so the ue0
interface shows up automatically. The only drawback is that I have the
3G only version of the S3, so my connection is slower, but I can live
with that, and on the upside is that since the new SIM card is
specifically for mobile broadband, I get a more generous data plan.

Version: GnuPG v2.0.22 (FreeBSD)


More information about the freebsd-questions mailing list