Re: systemd-networkd: switch between several static network setups on wired connection

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

 



Hi Alvin,

On 2023-03-29 22:55, Alvin Šipraga wrote:
> Hi Torsten,
>
> On Wed, Mar 29, 2023 at 02:58:05PM +0200, fi@xxxxxx wrote:
> >
> > Dear Systemd Folx,
> >
> >
> >
> > I have a laptop that I run at different locations with different
> > networks. I want to have static(!) network setup (address, gateway, DNS,
> > NTP) for my wired adapter on these networks. I can define setup for
> > each of them in a .network file matching my interface (eth0), but only
> > the alphabetically first of them is taken into account.
> >
> > For now I create a symbolic link to the desired config and restart
> > systemd-netword.
> >
> > Is there a more straight forward way for chosing the actual setup, for
> > instance using networkctl?
>
> Unless you have something that networkd can notice is different about
> the interface from one location to another (cf. [Match] in the
> systemd.network(5) man page [1]), you will have to give it a kick in
> order to change its behaviour.

thanks for clarification. I was afraid that I had missed something.

Obviously that behavior results from the concept to ignore all but the
first matching configuration. Presumably it would have remarkable
design impact to put them into a list to chose from.

> But restarting the entire daemon is not strictly necessary. You can
> update the symlink you described and then run 'networkctl reload' to
> make it reload the .network and .link files. I think you will then have
> to run 'networkctl reconfigure eth0' as well.
>
> [1] https://www.freedesktop.org/software/systemd/man/systemd.network.html#%5BMatch%5D%20Section%20Options

you are right - that is much more elegant.

> > Might there also be a chance to automatically chose a wired setup
> > depending on a local SSID visible?
>
> SSID is a wireless thing so it will not be something that a wired
> interface can match on.

I had not fully understood the logic of matching. If we had

  [Match]
      name = eth0
      SSID = my-wifi

would that mean, that "my-wifi" must be accessible via that interface
(AND logic) or could that mean we configure "eth0" while "my-wifi" is
visible on any interface (OR logic)? I had hoped for the latter. 

> But for wireless interfaces you can achieve what
> you want much better by using SSID= in the [Match] section.

yes of course :-) But wired connections have their advantages.

Best Regards

Torsten


-- 
------------------------------------------------------------------------
Torsten Finke
fi@xxxxxx

Ingenieurgemeinschaft IgH
Gesellschaft für Ingenieurleistungen mbH
Heinz-Bäcker-Str. 34
D-45356 Essen
------------------------------------------------------------------------




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

  Powered by Linux