My problem is related to USB tethering and network interfaces.
When I run ifconfig -a
, normally I see 3 interfaces - loopback, WiFi and Ethernet. I have defined gateway, netmask and broadcast for each one of them in /etc/networking/interfaces
.
Sometimes I connect my phone to my machine for USB tethering and when running ifconfig -a
I can see 1 more interface called enp0s20u2
. This interface is shown only when the phone is connected and USB tethering is enabled in it. In order to bring up that interface, I've added the following lines in /etc/networking/interfaces
:
# For USB tethering
auto enp0s20u2
iface enp0s20u2 inet dhcp
address 192.168.42.56
gateway 192.168.42.1
netmask 255.255.255.0
broadcast 192.168.42.255
This way, When I connect my phone, this interface is automatically brought up and configured.
The problem is that the systemd service can't start if the phone is not connected. The enp0s20u2
interface is unknown most of the time, Therefore systemctl
fails to bring it up on startup as well as when I manually run systemctl restart networking
.
Is there a way to assure this interface configuration won't make the service fail to start?
auto
. Yet, removingauto
will create the problem that you will need to perform theip link enp0s20u2 up
command by hand. To not run it by hand you may be able to setup aifplugd
service but then it ififplugd
that will fail on startup. A better option may benmcli
(NetworkManager).