Re: networkd: how to match the only interface?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 16, 2020 at 4:13 AM Roman Odaisky <roma@xxxxxxxxxxx> wrote:
Hi,

I would like to assign a static IP address to a server in a way that survives
hardware replacement. Basically I want the configuration to say: “Find the only
physical interface present and assign this static IP address to it. In the
unexpected case of finding multiple interfaces, assign the address to some
interface”.

The problem I’m trying to avoid is that if the hardware of a headless server
fails, then moving its drive(s) to another server may cause it to become
inaccessible if the name of the link becomes different.

Similarly, if I prepare a USB drive to troubleshoot headless server issues, I
need to have it assign an address to at least one interface without knowing in
advance what its name is.

What would be appropriate .link/.network entries that achieve this and avoid
assigning the same address to more than one interface or interfering with
virtual interfaces?

In this case I would just *disable* the persistent naming feature, so that you would always keep the kernel-assigned "eth0" name.

(This would be either setting NamePolicy= to an empty value in a .link file so that no naming policies are applied, or outright booting with the "net.ifnames=0" kernel parameter.)

This works perfectly fine as long as you have exactly one physical Ethernet interface, as you claimed. If you have multiple, one of them will still be "eth0" and will still get the IP address... you just can't be sure which one. (They might even swap after a reboot.)

--
Mantas Mikulėnas
_______________________________________________
systemd-devel mailing list
systemd-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux