# USB tether auto connect



## Dan MacDonald (Aug 24, 2017)

I make daily use of the tethering feature on my phone to access the internet. Under Linux, when I'm using networkmanager, it autoconnects the DHCP client to the USB ethernet interface that is created when I enable tethering.

To use tethering under FreeBSD, I have to run `dhclient ue0` as root but it seems that both the TrueOS network tool and the GhostBSD netmanager both lack the ability to autoconnect to usb ethernet. I have created tickets for both requesting this feature.

Until such features are implemented in those tools, what's the best or easiest way to configure dhclient/FreeBSD so that I can auto-connect to USB ethernet when it appears? I tried adding


```
ifconfig_ue0="DHCP"
```

To rc.conf with no success.


----------



## SirDice (Aug 24, 2017)

Dan MacDonald said:


> Until such features are implemented in those tools, what's the best or easiest way to configure dhclient/FreeBSD so that I can auto-connect to USB ethernet when it appears?


Have a look at devd(8) and specifically devd.conf(5). You can have an automatic script fire off when certain hardware is attached. That will allow you to run dhclient(8) whenever the device is attached.


----------



## Dan MacDonald (Aug 24, 2017)

Yes, it seems devd should be able to do what I want but I've not got it to work yet. I have tried adding:


```
attach 0 {
        device-name "ue[0-9]+";
        action "/sbin/dhclient $device-name";
};
```

To my /etc/devd.conf but that doesn't work as expected.


----------



## SirDice (Aug 24, 2017)

Try with notify instead. There are a few examples at the top that do something similar for PCCard (PCMCIA) network cards.


----------



## gfx (Aug 26, 2017)

I just realized that there is an extensive devd configuration example located at /usr/share/examples/etc/devd.conf The usage of notify event dispatcher is as follows:


```
#
# Try to start dhclient on Ethernet-like interfaces when the link comes
# up.  Only devices that are configured to support DHCP will actually
# run it.  No link down rule exists because dhclient automatically exits
# when the link goes down.
#
notify 0 {
    match "system"        "IFNET";
    match "type"        "LINK_UP";
    media-type        "ethernet";
    action "/etc/rc.d/dhclient quietstart $subsystem";
};
```


----------

