Automatic network start on USB-Netdevice insert

There are devices connecting the computer to ethernet via USB. It would be nice to raise the network, after the USB netdevice is plugged into the computer

Getting the right kernel module
First have a look into the kernel modules, if there is the appropriate module servicing your device. The USB network device modules are located in:

There select all devices as modules drivers. Compile and install the modules

You may find further information in the Gentoo linux kernel guide.

First Network device start
If you successfully installed the device driver modules, have a look what udev thinks of your device. Today almost all Gentoo installations have udev activated. Have a look in the Gentoo udev guide, if you're not shure.

Now plug in your device. lsusb should list the device and its name and hardware. (This is an example with AX88187 hardware) lsusb If you have udev activated and a device driver module, the system logs should list your device, too. /var/log/messages dmesg

Rename the network device
You may leave the network device name to "eth1" and skip this section. I like to rename the device. There are 2 ways to rename it, net config and udev.

Rename in /etc/conf.d/net
The Gentoo net config file allows to rename a network device. Simply add /etc/conf.d/net Be careful, always use the device eth1 for your USB device. Else you rename a different device, which you won't want to do.

Rename in /etc/udev/rules.d/70-persistent-net.rules
The other way renames every USB device with a certain hardware ID to "usb0". You have to change the entry in the persistent net rules from udev from "eth1" to "usb0".

Upon your first insert of the USB device, udev has made an entry in the persistent net list. Look for the entry with the same device ID of your USB device (e.g. "USB device 0x0b95:0x1780 (usb)") and change the entry 'NAME=' from "eth1" to "usb0".

If you don't have an entry for your device, check if your device is detected and known to the system. Have a look in the previous section. Also check, that persistent net rules are activated in your system config /etc/conf.d/udev

Afterwards it may look like this: /etc/udev/rules.d/70-persistent-net.rules This however only works for your actual USB device with a certain device ID. You have to redo this step for every USB net device.

Automatic network start
To have an automatic start of connectivity use  or. The net example configuration (/etc/conf.d/net.example) lists both. Just and link the ethernet interface to the network script

You may add a dhcp entry to the network config. Using dhcp should be default handling if no entry is listed in the config file. /etc/conf.d/net

finish
Now your network connection should appear as net device "usb0" and instantly connect to your network if your net cable is plugged in. "ifconfig" lists your device. ifconfig You may change your MTU of your device, if you own a gigabit net adapter. Add in to the network config file /etc/conf.d/net