0

currently I'm playing with USB tethering between a raspi and a Linux PC.
On the Linux pc I configured the USB interface to get a static ip once it's connected. This is managed by the Networkmanager and works fine.
On the raspi I configured a static ip via `/etc/network/interfaces`
allow-hotplug usb0
iface usb0 inet static
  address 169.254.100.2
  netmask 255.255.255.252
  gateway 169.254.100.1

So now when I connect the raspi via USB to the Linux PC, the interface is detected and I can ssh into the raspi.
But if I reboot my Linux PC, I cannot reach the raspi any more. And now I found out that the raspi loses it's ip but does not reassign it if the Linux PC is back up. I always have to execute ip a add 169.254.100.2/30 dev usb0 on the raspi to get the network back.
Can you please give me any hint on what to do to get the network automatically back? At the moment I'm out of ideas.

Many thanks in advance for any help.

  • 1
    169. IS NOT a static IP. It is a Link-local address. – Milliways Oct 15 at 21:56
  • @Milliways: If you assign it this way, it IS a static IP address, but it is in the range assigned to APIPA (169.254.0.0/16). You should not do that of course. – Ljm Dullaart Oct 17 at 17:36
  • @LjmDullaart true, but it remains unroutable. – Milliways Oct 17 at 22:39
3

You ignored the note in /etc/network/interfaces:

Please note that this file is written to be used with dhcpcd
For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

Please reset it to its default setting without any stanza:

rpi ~$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

and use only /etc/dhcpcd.conf for your configuration if you don't know the impact of using /etc/network/interaces together with dhcpcd. You cannot simply mix it.

| improve this answer | |
  • Will that take care of his use of the link local address also? – Seamus Oct 15 at 22:11
  • @Seamus link local addressing is enabled by default and should still work. – Ingo Oct 15 at 22:29
  • Yeah - I was referring to his comment: I always have to execute ip a add 169.254.100.2/30 dev usb0 on the raspi to get the network back. – Seamus Oct 15 at 22:33
  • 1
    @Seamus Such a command is not needed if he don't mix up things. – Ingo Oct 15 at 22:36
  • After playing around with the static ip address in /etc/dhcpcd.conf it turned out that if I use e.g. 192.254.100.2/30 the whole thing just works all the time. But why can't I use the local link address range 169.254.100.0? – Chris Oct 18 at 12:52
0

Thank you for all your helpful suggestions!
The solution for my problem was to uninstall dhcpcd5
apt purge dhcpcd5 and only using /etc/network/interfaces
After doing this I get my static ip (even if it's a local link address) back every time.
Even when using etc/dhcpcd.conf only (like @ingo suggested), my raspi always lost it's address if I use 196.254.100.2.
It only worked if I used a non local link address, for example 192.254.100.2.
But using the link local address to me is essential, since it should not interfere with any network connected to the host, whatever ip address it may have.

To be more precisely, here's what the dhcpcd logged when I used a static ip of the link local range

Feb 14 10:12:01 pi-display dhcpcd[252]: usb0: waiting for carrier
Feb 14 10:12:01 pi-display dhcpcd[252]: usb0: carrier acquired
Feb 14 10:12:01 pi-display dhcpcd[252]: DUID 00:01:00:01:23:f7:fb:72:00:22:82:ff:ff:22
Feb 14 10:12:01 pi-display dhcpcd[252]: usb0: IAID 82:ff:ff:22
Feb 14 10:12:01 pi-display dhcpcd[252]: usb0: adding address fe80::e2fc:7c06:450:7284
Feb 14 10:12:01 pi-display dhcpcd[252]: usb0: probing address 169.254.100.2/30
Feb 14 10:12:02 pi-display dhcpcd[252]: usb0: soliciting an IPv6 router
Feb 14 10:12:06 pi-display dhcpcd[252]: usb0: using static address 169.254.100.2/30
Feb 14 10:12:06 pi-display dhcpcd[252]: usb0: adding route to 169.254.100.0/30
Feb 14 10:12:06 pi-display dhcpcd[252]: usb0: adding default route via 169.254.100.1
Feb 14 10:12:06 pi-display dhcpcd[252]: usb0: deleting route to 169.254.100.0/30
Feb 14 10:12:06 pi-display dhcpcd[252]: usb0: deleting default route via 169.254.100.1
Feb 14 10:12:15 pi-display dhcpcd[252]: usb0: no IPv6 Routers available

And here's the log when I use a normal ip like 192.254.100.2:

Feb 14 10:12:01 pi-display dhcpcd[262]: usb0: waiting for carrier
Feb 14 10:12:01 pi-display dhcpcd[262]: usb0: carrier acquired
Feb 14 10:12:01 pi-display dhcpcd[262]: DUID 00:01:00:01:23:f7:fb:72:00:22:82:ff:ff:22
Feb 14 10:12:01 pi-display dhcpcd[262]: usb0: IAID 82:ff:ff:22
Feb 14 10:12:01 pi-display dhcpcd[262]: usb0: adding address fe80::e2fc:7c06:450:7284
Feb 14 10:12:01 pi-display dhcpcd[262]: usb0: probing address 192.254.100.2/30
Feb 14 10:12:01 pi-display dhcpcd[262]: usb0: soliciting an IPv6 router
Feb 14 10:12:07 pi-display dhcpcd[262]: usb0: using static address 192.254.100.2/30
Feb 14 10:12:07 pi-display dhcpcd[262]: usb0: adding route to 192.254.100.0/30
Feb 14 10:12:07 pi-display dhcpcd[262]: usb0: adding default route via 192.254.100.1
Feb 14 10:12:15 pi-display dhcpcd[262]: usb0: no IPv6 Routers available
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.