How to configure network using systemd-networkd in Yocto: Difference between revisions
Jump to navigation
Jump to search
(Created page with "== How to configure network using systemd-networkd in Yocto == When using '''Yocto Project''' it sometimes may be necessary to setup a '''static IP address''' via a custom re...") |
No edit summary |
||
| Line 43: | Line 43: | ||
ClientIdentifier=mac | ClientIdentifier=mac | ||
Below is an example of a recipe to manage that | Below is an example of a possible solution | ||
Create a '''.bbappend''' recipe to manage that and replace the existing '''wired.network''' file with your custom one | |||
meta-custom/ | |||
└─ recipes-core/ | |||
└── systemd-conf | |||
├── systemd-conf | |||
│ └── wired.network | |||
└── systemd-conf_%.bbappend | |||
The recipe systemd-conf_%.bbappend | |||
# recipes-core/systemd-conf/systemd-conf_%.bbappend | |||
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" | |||
The network file | |||
# wired.network | |||
[Match] | |||
Type=ether | |||
Name=!veth* | |||
KernelCommandLine=!nfsroot | |||
KernelCommandLine=!ip | |||
[Network] | |||
Address=192.168.0.184/24 | |||
Gateway=192.168.0.1 | |||
DNS=1.1.1.1 | |||
[DHCP] | |||
UseMTU=yes | |||
RouteMetric=10 | |||
ClientIdentifier=mac | |||
Revision as of 14:00, 15 March 2025
How to configure network using systemd-networkd in Yocto
When using Yocto Project it sometimes may be necessary to setup a static IP address via a custom recipe.
When the network manager is systemd-networkd the file usually responsible for that is /lib/systemd/network/80-wired.network
Simply change it from the original
# cat /lib/systemd/network/80-wired.network [Match] Type=ether Name=!veth* KernelCommandLine=!nfsroot KernelCommandLine=!ip [Network] DHCP=yes [DHCP] UseMTU=yes RouteMetric=10 ClientIdentifier=mac
To the following
# cat /lib/systemd/network/80-wired.network [Match] Type=ether Name=!veth* KernelCommandLine=!nfsroot KernelCommandLine=!ip [Network] Address=192.168.0.184/24 Gateway=192.168.0.1 DNS=1.1.1.1 [DHCP] UseMTU=yes RouteMetric=10 ClientIdentifier=mac
Below is an example of a possible solution
Create a .bbappend recipe to manage that and replace the existing wired.network file with your custom one
meta-custom/
└─ recipes-core/
└── systemd-conf
├── systemd-conf
│ └── wired.network
└── systemd-conf_%.bbappend
The recipe systemd-conf_%.bbappend
# recipes-core/systemd-conf/systemd-conf_%.bbappend
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
The network file
# wired.network
[Match]
Type=ether
Name=!veth*
KernelCommandLine=!nfsroot
KernelCommandLine=!ip
[Network]
Address=192.168.0.184/24
Gateway=192.168.0.1
DNS=1.1.1.1
[DHCP]
UseMTU=yes
RouteMetric=10
ClientIdentifier=mac