Solved Automating 'dhclient ue0' when tethering USB

And where did you put the rule.
The reason you use /usr/local/etc/devd is so you can easily spot your works. Instead of polluting system rules in /etc/devd.
 
And where did you put the rule.
The reason you use /usr/local/etc/devd is so you can easily spot your works. Instead of polluting system rules in /etc/devd.
cat /usr/local/etc/devd/usb_tethering.conf:-

Code:
attach 100 {
    match "device-name" "ue0";
    action "/sbin/dhclient ue0";
};

This worked for some time, but no longer does. Now I need to run dhclient ue0 after I have attached a USB cable to my phone and enabled USB tether.

It just stopped working after a power cut and reboot.
 
I'll test this method and I'll let you know.
However have you checked on your phone too?
There is nothing to check on my phone.

All I do is enable Tethering USB on my phone when I have connected the the USB cable to it.

What happened previously was that dhclient ue0 would automatically run, but now, for some reason I need to do it manually.
 
There is nothing to check on my phone.

All I do is enable Tethering USB on my phone when I have connected the the USB cable to it.

What happened previously was that dhclient ue0 would automatically run, but now, for some reason I need to do it manually.

The solution you proposed doesn't work for me too.
Dhclient is not triggered when I plug my phone. 🤔

I guess the method has changed. 🤷‍♂️
 
I used to connect to the internet over USB tethering a few years ago. The devd configuration used then is still on my system (15.1-RELEASE-p2 now), and still working:

/usr/local/etc/devd/usb_tethering.conf
Code:
# Configure USB tethering devd event. Example taken from https://wiki.freebsd.org/Devd

notify 20 {
    match "system"        "ETHERNET";
    match "type"        "IFATTACH";
    match "subsystem"    "ue[0-9]+";
    action "/sbin/dhclient $subsystem";
};

Upon activation of the USB tethering on my phone, an IP address is assigned automatically:
Code:
% ifconfig ue0
ue0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=0
    ether a0:cf:76:12:d4:44
    inet 192.168.53.137 netmask 0xffffff00 broadcast 192.168.53.255
    inet6 fe80::cf:76ff:fe12:d444%ue0 prefixlen 64 scopeid 0x7
    nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

There is unusual activity on the console, printed repeatedly. Despite the messages, the internet connection remains stable, using it to access the forums and write this post.
Code:
%  dmesg  -a
ugen0.3: <SAMSUNG SAMSUNGAndroid> at usbus0
ugen0.3: <SAMSUNG SAMSUNGAndroid> at usbus0 (disconnected)
ugen0.3: <SAMSUNG SAMSUNGAndroid> at usbus0
ugen0.3: <SAMSUNG SAMSUNGAndroid> at usbus0 (disconnected)
ugen0.3: <SAMSUNG SAMSUNGAndroid> at usbus0
ugen0.3: <SAMSUNG SAMSUNGAndroid> at usbus0 (disconnected)
ugen0.3: <SAMSUNG SAMSUNGAndroid> at usbus0
urndis0 on uhub0
urndis0: <SAMSUNG SAMSUNGAndroid, class 224/0, rev 2.00/ff.ff, addr 2> on usbus0
ue0: <USB Ethernet> on urndis0
ue0: Ethernet address: a0:cf:76:12:d4:44
ugen0.3: <SAMSUNG SAMSUNGAndroid> at usbus0 (disconnected)
urndis0: at uhub0, port 4, addr 2 (disconnected)
Aug 24 16:44:13 ****** dhclient[8588]: receive_packet failed on ue0: Device not configured
Aug 24 16:44:13 ****** dhclient[8588]: ioctl(SIOCGIFFLAGS) on ue0: Operation not permitted
Aug 24 16:44:13 ****** dhclient[8588]: Interface ue0 no longer appears valid.
Aug 24 16:44:13 ****** dhclient[8588]: No live interfaces to poll on - exiting.
Aug 24 16:44:13 ****** dhclient[8588]: exiting.
Aug 24 16:44:13 ****** dhclient[8588]: connection closed
Aug 24 16:44:13 ****** dhclient[8588]: exiting.
urndis0: detached
...
ugen0.3: <SAMSUNG SAMSUNGAndroid> at usbus0
urndis0 on uhub0
urndis0: <SAMSUNG SAMSUNGAndroid, class 224/0, rev 2.00/ff.ff, addr 2> on usbus0
ue0: <USB Ethernet> on urndis0
ue0: Ethernet address: a0:cf:76:12:d4:44
ugen0.3: <SAMSUNG SAMSUNGAndroid> at usbus0 (disconnected)
urndis0: at uhub0, port 4, addr 2 (disconnected)
Aug 24 17:02:29 ****** dhclient[13506]: receive_packet failed on ue0: Device not configured
urndis0: detached
Aug 24 17:02:29 ****** dhclient[13506]: ioctl(SIOCGIFFLAGS) on ue0: Operation not permitted
Aug 24 17:02:29 ****** dhclient[13506]: Interface ue0 no longer appears valid.
Aug 24 17:02:29 ****** dhclient[13506]: No live interfaces to poll on - exiting.
Aug 24 17:02:29 ****** dhclient[13506]: exiting.
Aug 24 17:02:29 ****** dhclient[13506]: connection closed
Aug 24 17:02:29 ****** dhclient[13506]: exiting.
ugen0.3: <SAMSUNG SAMSUNGAndroid> at usbus0
urndis0 on uhub0
urndis0: <SAMSUNG SAMSUNGAndroid, class 224/0, rev 2.00/ff.ff, addr 2> on usbus0
ue0: <USB Ethernet> on urndis0
ue0: Ethernet address: a0:cf:76:12:d4:44
Aug 24 17:05:40 ****** dhclient[7871]: send_packet: Network is down
Aug 24 17:06:11 ****** syslogd: last message repeated 4 times
Aug 24 17:08:22 ****** syslogd: last message repeated 9 times
Aug 24 17:18:00 ****** syslogd: last message repeated 21 times
 
I used to connect to the internet over USB tethering a few years ago. The devd configuration used then is still on my system (15.1-RELEASE-p2 now), and still working:

/usr/local/etc/devd/usb_tethering.conf
Code:
# Configure USB tethering devd event. Example taken from https://wiki.freebsd.org/Devd

notify 20 {
    match "system"        "ETHERNET";
    match "type"        "IFATTACH";
    match "subsystem"    "ue[0-9]+";
    action "/sbin/dhclient $subsystem";
};
[/spoiler]


I had
Code:
attach 100 {
<------>match "device-name" "ue0";
<------>action "/sbin/dhclient ue0";
};

which worked originally but no longer does so.

I'll try changing it to see if it works.

A few minutes later....

It does work, so I'm mystified why it did work previously with the previous setting.

Ideally this would work as soon as I attach the the USB cable to the phone but have no idea if I can induce the phone to automatically switch on 'Tethering USB' when a cable is attached.
 
It does not work on my side, maybe do I miss some options on my rc.conf? 🤷‍♂️
Just to make sure: I assume devd isn't disabled in /etc/rc.conf (devd_enable="N0" ).

Next what you can try is to start the devd daemon in debug mode as described in the wiki, activate USB tethering on the phone, compare what is printed on screen with the devd config file.
 
Back
Top