You are not logged in.

#1 2018-05-08 08:07:52

pethead
Member
From: RU
Registered: 2015-02-25
Posts: 48

[SOLVED] How to route add when network device plugged on USB.

I have some working network settings that operate when some device is plugged.

How to port them to Archlinux with netctl? Within ifplugd?

/etc/network/interfaces

# plug device
allow-hotplug usb0
iface usb0 inet dhcp
up route add -net 17.0.0.0 netmask 255.0.0.0 gw 192.168.80.1

What I did:

create /etc/netctl/enp0s6u2 with IP=dhcp, Routes as described.

If run sudo systemctl start netctl-ifplugd@enp0s6u2 then ip route added as described at profile starting by ifplugd.

if USB unplugged then route disappeared. And netctl-ifplugd@enp0s6u2 stopped and exited.

How to automate detect plugging?

Last edited by pethead (2018-05-10 07:11:24)


This Must Be The Place I Waited Years To Leave

Offline

#2 2018-05-09 22:34:01

gerdesj
Member
Registered: 2016-04-17
Posts: 13

Re: [SOLVED] How to route add when network device plugged on USB.

NetworkManager can do this sort of thing very well.  On this laptop, my ethernet NIC is provided via a USB dongle.  There is nmcli and nmtui for shell use and lots of very decent GUI front ends.

Offline

#3 2018-05-10 03:50:09

pethead
Member
From: RU
Registered: 2015-02-25
Posts: 48

Re: [SOLVED] How to route add when network device plugged on USB.

gerdesj wrote:

NetworkManager can do this sort of thing very well.  On this laptop, my ethernet NIC is provided via a USB dongle.  There is nmcli and nmtui for shell use and lots of very decent GUI front ends.

Can you publish your settings how to do it?

For anyone curious, here is the complete set of instructions I used for switching from interfaces to systemd-networkd instead of netctl or NM.

netctl, ifplugd packages were removed.

To switch to systemd-networkd, make the following changes:
systemctl enable systemd-networkd.service
systemctl enable systemd-resolved.service
rm /etc/resolv.conf
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

Create /etc/systemd/network/10_my.network with this content:
[Match]
Name=enp0s6u2

[Network]
DHCP=no
Address=192.168.80.2/24
Gateway=192.168.80.1
[Route]
Destination=17.0.0.0/8
Gateway=192.168.80.1

And now:
chmod a+r /etc/systemd/network/10_my.network

After that and plug\unplug USB I have described route in route table.

Second gateway in Route section may be absent.

Last edited by pethead (2018-05-10 12:45:11)


This Must Be The Place I Waited Years To Leave

Offline

Board footer

Powered by FluxBB