[systemd-devel] networkd: how to match the only interface?
Mantas Mikulėnas
grawity at gmail.com
Tue Jun 16 07:44:00 UTC 2020
On Tue, Jun 16, 2020 at 4:13 AM Roman Odaisky <roma at qwertty.com> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20200616/43dfb46e/attachment.htm>
More information about the systemd-devel
mailing list