From owner-freebsd-questions@FreeBSD.ORG Thu May 1 11:07:21 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 474759B5 for ; Thu, 1 May 2014 11:07:21 +0000 (UTC) Received: from mail-lb0-x236.google.com (mail-lb0-x236.google.com [IPv6:2a00:1450:4010:c04::236]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BEFC21C94 for ; Thu, 1 May 2014 11:07:20 +0000 (UTC) Received: by mail-lb0-f182.google.com with SMTP id l4so2033035lbv.41 for ; Thu, 01 May 2014 04:07:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=v+IMpfKM7asJQjkRXIEJtlP38wbLiMwmTs26gniMlP4=; b=lRKVW1/74/UFVaPPTaVGCusqdmX2nszpFKgGY8b4dD7wCkQNehRUDLdMvkTry+Ae+g dq3cgA7vnXT8f8tAU9ngE/X8Wp0nnpUsN7wk3u3SYkjEyZkZnlQn3xmmpBaceWsm2T/Q h7Idb/rrwPElLMM+cDnts2R0NtJ8J1T261EjMbupuPshhRD45J5ug3uJZ7rchcCjF5/U JO5TIAgzi9/3QdWnquDAdEysU3rJpqrz5vBCAvz/xOivVCNlqncYPDUnRu3peBsW5637 rSul97fvcfQYNudauPbNIaDgo5bB9rJ+h4bc26VQxFeS5Pehyiqg0r2jG8jXCkjh5xUW FXCA== X-Received: by 10.112.139.166 with SMTP id qz6mr6752883lbb.13.1398942436819; Thu, 01 May 2014 04:07:16 -0700 (PDT) Received: from lazlar.no-ip.biz (109.58.144.255.bredband.tre.se. [109.58.144.255]) by mx.google.com with ESMTPSA id jm3sm29539186lbc.29.2014.05.01.04.07.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 04:07:15 -0700 (PDT) Message-ID: <53622AE0.4070804@gmail.com> Date: Thu, 01 May 2014 13:07:12 +0200 From: Rolf Nielsen User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: User questions Subject: Re: Running a command when a specific interface is created or destroyed References: <201404241713.s3OHDXkZ013843@fire.js.berklix.net> In-Reply-To: <201404241713.s3OHDXkZ013843@fire.js.berklix.net> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "Julian H. Stacey" 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, 01 May 2014 11:07:21 -0000 -----BEGIN PGP SIGNED MESSAGE----- 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. > http://www.berklix.com/~jhs/src/bsd/fixes/FreeBSD/src/jhs/etc/devd/berklix.conf > > 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. Rolf -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (FreeBSD) iQIcBAEBAgAGBQJTYirgAAoJEB1OKfQ0M8Tgq9QQAODMQklTJCwb8efXvyiCXy1N excB9DkaQhuUtWclasBsieGb33mrlHJIMoQdSOHWEOElI5u0KQq/pN6015ud00B6 dD7wBtvpOxEQ/A0NyQ+yhbk5JsYq2Soe95B799MMwtOmQTAQgWXTi35oHYuT4Ibd 93siJ/Lu53VSkguyCMQXyxbJYC3NVjMPJ83UWO8zzd2FNxygoDE87rrYmyZ2/Uvj budwTKEtq97kMUMNO8aixfU01zhjc6rGACUmtNHrz6VyXfklsLVQCd06GvLg3VH1 l6+s9Fz8Pz5O+KXHSfLGH2DXrHoNPiqMdxtbwuEj8abI786vp+yVHNGma1+YsbNV xFe+76AvAp7/UXvFKrH5N3M5uLEOlRwhpeX+XPgxb+Xyaj7pZIwP4MYevHoIxt62 +dgRSrXGsYv40dYBURv39dx47T4Gds1OLIMCV2EHjs8DPLVeBZQY3W3EQVIL8XTr IqKlM3Ry7nmt5vLE/lwQxwWhWnzTOJqk2u8ANE1/kOpUEoiUBfqSz9Qz60+GSfmq dRIuEuQ/9CE3/Cnqj++myq8tP1HUpeiwc7Pk32nePK0q/Bx4U47vLu0oPH41Hzs+ XAK124mc5Z+MkQ4xQTUh0WuQebrWTduOdtz2jacBD4M9WTaRWCm29KOn3K/fIlFU 8UhNUAg440lznRcfi8oD =xyZ8 -----END PGP SIGNATURE-----