Automating 'dhclient ue0' when tethering USB

what about a devd.conf

Code:
/usr/local/etc/devd.conf

this is what i use for my keyboard

i guess you could do the same thing to run dhclient ue0


Code:
#=========================================================================#
# devd.conf
#=========================================================================#

#=========================================================================#
# ducky one 2 mini
#=========================================================================#

attach 100 {
        device-name "uhid[0-9]+";                                                           
        match "vendor"  "0x0416"; # (1)
        match "product" "0x0123"; # (2)

    #
    # Do not add -d flag ! if you do it devd will never detach to background
    # because usbhidaction will run in foreground !
    #
    # Remember you can add arguments after /etc/usbhidaction.conf like
    # action "/usr/bin/usbhidaction -f $device-name -c /etc/usbhidaction.conf /dev/mixer1 2"
    #
        action "/usr/bin/usbhidaction -f $device-name -c /usr/local/etc/usbhidaction.conf";
};
 
To summarize:

Create this file and populate it.
/usr/local/etc/devd/usb_tethering.conf
Code:
notify 20 {
    match    "system"    "ETHERNET";
    match    "type"        "IFATTACH";
    match    "subsystem"    "ue[0-9]+";
    action    "/sbin/dhclient $subsystem";
};
Then service devd restart.

Running devd with the -d flag will show it in action.
service devd stop && devd -d
If you have any errors it will tell on startup what file and line numbers that have issues.

No other settings are needed. Create a devd rule configuration file in the proper location and restart devd.
 
Last edited:
To summarize:

Create this file and populate it.
/usr/local/etc/devd/usb_tethering.conf
Code:
notify 20 {
    match    "system"    "ETHERNET";
    match    "type"        "IFATTACH";
    match    "subsystem"    "ue[0-9]+";
    action    "/sbin/dhclient $subsystem";
};
Then service devd restart.

Running devd with the -d flag will show it in action.
service devd stop && devd -d
If you have any errors it will tell on startup what file and line numbers that have issues.

No other settings are needed. Create a devd rule configuration file in the proper location and restart devd.
I just tried this but something doesn't work.

Where should I look?

cat usb_tethering.conf:-
Code:
notify 20 {
        match "system"          "ETHERNET";
        match "type"            "IFATTACH";
        match "subsystem"       "ue[0-9}+";
        action "/sbin/dhclient $subsystem";
};
 
Do you see parsing usb_tethering.conf ?

# service devd stop && devd -d
Code:
Stopping devd.
Waiting for PIDS: 64207.
Parsing /etc/devd.conf
setting wifi-driver-regex=(ath|ath[0-9]+k|bwi|bwn|ipw|iwlwifi|iwi|iwm|iwn|malo|mwl|mt79|mtw|otus|ral|rsu|rtw|rtwn|rum|run|uath|upgt|ural|urtw|wpi|wtap|zyd)[0-9]+
Parsing files in /etc/devd
Parsing /etc/devd/syscons.conf
Parsing /etc/devd/uath.conf
Parsing /etc/devd/power_profile.conf
Parsing /etc/devd/zfs.conf
Parsing /etc/devd/snd.conf
Parsing /etc/devd/devmatch.conf
Parsing /etc/devd/dhclient.conf
Parsing /etc/devd/iwmbtfw.conf
Parsing /etc/devd/asus.conf
Parsing /etc/devd/nvmf.conf
Parsing /etc/devd/moused.conf
Parsing /etc/devd/autofs.conf
Parsing /etc/devd/hyperv.conf
Parsing /etc/devd/rtlbtfw.conf
Parsing /etc/devd/ulpt.conf
Parsing /etc/devd/bluetooth.conf
Parsing files in /usr/local/etc/devd
Parsing /usr/local/etc/devd/automount_devd.conf
Parsing /usr/local/etc/devd/cups.conf
Parsing /usr/local/etc/devd/usb_tethering.conf

Am I correct in thinking that after inserting a USB cable into my smartphone and selecting Tethering USB, this should automatically run dhclient ue0 ?

Can I output a message as part of the 'action' line ?
 
Am I correct in thinking that after inserting a USB cable into my smartphone and selecting Tethering USB, this should automatically run dhclient ue0 ?
Yes
Code:
Processing event '+axge0 at bus=0 hubaddr=1 port=18 devaddr=4 interface=0 ugen=ugen0.4 vendor=0x0b95 product=0x1790 devclass=0x00 devsubclass=0x00 devproto=0x00 sernum="00C70A20" release=0x0200 mode=host intclass=0xff intsubclass=0xff intprotocol=0x00 on uhub0'
Pushing table
setting *=+axge0 at bus=0 hubaddr=1 port=18 devaddr=4 interface=0 ugen=ugen0.4 vendor=0x0b95 product=0x1790 devclass=0x00 devsubclass=0x00 devproto=0x00 sernum="00C70A20" release=0x0200 mode=host intclass=0xff intsubclass=0xff intprotocol=0x00 on uhub0
setting _=axge0 at bus=0 hubaddr=1 port=18 devaddr=4 interface=0 ugen=ugen0.4 vendor=0x0b95 product=0x1790 devclass=0x00 devsubclass=0x00 devproto=0x00 sernum="00C70A20" release=0x0200 mode=host intclass=0xff intsubclass=0xff intprotocol=0x00 on uhub0
setting timestamp=1782256833.683211
setting vm_guest=none
setting device-name=axge0
setting bus=0
setting hubaddr=1
setting port=18
setting devaddr=4
setting interface=0
setting ugen=ugen0.4
setting vendor=0x0b95
setting product=0x1790
setting devclass=0x00
setting devsubclass=0x00
setting devproto=0x00
setting sernum=00C70A20
setting release=0x0200
setting mode=host
setting intclass=0xff
setting intsubclass=0xff
setting intprotocol=0x00
setting bus=uhub0
Processing attach event
Testing device-name=axge0 against ^ed50$, invert=0
Testing device-name=axge0 against ^ukbd0$, invert=0
Testing device-name=axge0 against ^ubt[0-9]+$, invert=0
Testing device-name=axge0 against ^(ath|ath[0-9]+k|bwi|bwn|ipw|iwlwifi|iwi|iwm|iwn|malo|mwl|mt79|otus|ral|rsu|rtw|rtwn|rum|run|uath|upgt|ural|urtw|wpi|wtap|zyd)[0-9]+$, invert=0
Popping table
 
Back
Top