From owner-freebsd-questions@FreeBSD.ORG Thu Apr 24 14:51:17 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BB1E7A1E for ; Thu, 24 Apr 2014 14:51:17 +0000 (UTC) Received: from wonkity.com (wonkity.com [67.158.26.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "wonkity.com", Issuer "wonkity.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 6A67A1389 for ; Thu, 24 Apr 2014 14:51:17 +0000 (UTC) Received: from wonkity.com (localhost [127.0.0.1]) by wonkity.com (8.14.8/8.14.8) with ESMTP id s3OEp8nK005695 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 24 Apr 2014 08:51:09 -0600 (MDT) (envelope-from wblock@wonkity.com) Received: from localhost (wblock@localhost) by wonkity.com (8.14.8/8.14.8/Submit) with ESMTP id s3OEp819005692; Thu, 24 Apr 2014 08:51:08 -0600 (MDT) (envelope-from wblock@wonkity.com) Date: Thu, 24 Apr 2014 08:51:08 -0600 (MDT) From: Warren Block To: Rolf Nielsen Subject: Re: Running a command when a specific interface is created or destroyed In-Reply-To: <53591F01.4020108@gmail.com> Message-ID: References: <53591F01.4020108@gmail.com> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (wonkity.com [127.0.0.1]); Thu, 24 Apr 2014 08:51:09 -0600 (MDT) Cc: User questions X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Apr 2014 14:51:17 -0000 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.