Setup a static IP address - systemd


Konstantin Kletschke
 

Dear yocto, community,

I have a yocto build running on a Beaglebone Black with systemd enabled.
No /etc/init.d, no /etc/network/interfaces.

How do I set up a static IP Address for eth0?
The system always does an udhcpc request and uses that.

I have
systemd-networkd.service loaded active running
and tryed the following file in /etc/systemd/network:

# cat eth0.network
[Match]
Name=eth0

[Network]
Address=10.2.3.4/24
Gateway=10.2.3.1
DNS=1.1.1.1


Kind Regards
Konstantin


--
INSIDE M2M GmbH
Konstantin Kletschke
Berenbosteler Straße 76 B
30823 Garbsen

Telefon: +49 (0) 5137 90950136
Mobil: +49 (0) 151 15256238
Fax: +49 (0) 5137 9095010

konstantin.kletschke@...
http://www.inside-m2m.de

Geschäftsführung: Michael Emmert, Derek Uhlig
HRB: 111204, AG Hannover


Chen Qi
 

I think you're having a higher priority configuration file taking effect.
Check /lib/systemd/network and /run/systemd/network.
Maybe renaming your configuration file to 00-eth0.network would solve the problem.

Regards,
Qi

-----Original Message-----
From: yocto@... <yocto@...> On Behalf Of Konstantin Kletschke
Sent: Monday, February 27, 2023 6:13 PM
To: yocto@...
Subject: [yocto] Setup a static IP address - systemd

Dear yocto, community,

I have a yocto build running on a Beaglebone Black with systemd enabled.
No /etc/init.d, no /etc/network/interfaces.

How do I set up a static IP Address for eth0?
The system always does an udhcpc request and uses that.

I have
systemd-networkd.service loaded active running and tryed the following file in /etc/systemd/network:

# cat eth0.network
[Match]
Name=eth0

[Network]
Address=10.2.3.4/24
Gateway=10.2.3.1
DNS=1.1.1.1


Kind Regards
Konstantin


--
INSIDE M2M GmbH
Konstantin Kletschke
Berenbosteler Straße 76 B
30823 Garbsen

Telefon: +49 (0) 5137 90950136
Mobil: +49 (0) 151 15256238
Fax: +49 (0) 5137 9095010

konstantin.kletschke@...
http://www.inside-m2m.de

Geschäftsführung: Michael Emmert, Derek Uhlig
HRB: 111204, AG Hannover


Konstantin Kletschke
 

On Mon, Feb 27, 2023 at 01:28:13PM +0000, Chen, Qi wrote:
I think you're having a higher priority configuration file taking effect.
Check /lib/systemd/network and /run/systemd/network.
Maybe renaming your configuration file to 00-eth0.network would solve the problem.
Yes indeed. I am searching the web for ages for this, my colleauge also
found out within a couple of minutes :-|

Renaming the file having an additional prefix like "10-" works like a charme.
I suspect the number has to be lower than the 80 found in many files in
/lib/systemd/network...

Thanks for your provided solution, many thanks!

Kind Regards
Konstantin





--
INSIDE M2M GmbH
Konstantin Kletschke
Berenbosteler Straße 76 B
30823 Garbsen

Telefon: +49 (0) 5137 90950136
Mobil: +49 (0) 151 15256238
Fax: +49 (0) 5137 9095010

konstantin.kletschke@...
http://www.inside-m2m.de

Geschäftsführung: Michael Emmert, Derek Uhlig
HRB: 111204, AG Hannover