5

I have an USB ethernet adapter, but I am not sure how to configure it that the network is set up properly when the adapter is plugged in and out. Can I add something to netctl's config file to link it to the plugging of the hardware?

2
  • what does lsusb, ifconfig, and dmesg or journalctl show? You might also want to check here
    – SailorCire
    Commented Dec 6, 2014 at 22:08
  • As it changes, I set the device name to enp2s3.
    – John
    Commented Dec 6, 2014 at 22:11

2 Answers 2

1

The first thing you want to do is to create a udev rule which corresponds to the NIC you're plugging in and out. plug in NIC

udevadm info -a -p /sys/class/net/yourdeviceskernelname

For example, udevadm info -a -p /sys/class/net/eth1

Make the udev rule match the output of above: sudo nano /etc/udev/rules.d/10-usb-nic
KERNEL=="yourdev*", ATTR{address}=="11:22:33:44:55:66",
NAME="usb"

Then create a systemd-networkd unit to match the NIC. sudo nano /etc/systemd/network/10-usb.network
[Match]
Name=yourdeviceskernelname
[Network]
DHCP=v4 #for example
See more on networkd here.

0

Since you're using a newer version of udev, you should be fine like when you turn on or off the wireless switch on your laptop.

If you want a script to be run automatically when you plug it in or out then you need to add a udev rule to /etc/udev/rules.d

1
  • I just want the normal start/stop actions to be taken. Is this possible without writing a script that basically just does "systemctl stop netctl@enp2s3"? Because at the moment it is still considered active after unplugging.
    – John
    Commented Dec 7, 2014 at 0:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .