Configure wired network interface with dhcp
cover Configure wired network interface with dhcp
From: Kai Kang <[email protected]>
Configure wired network interface with dhcp when use systemd as default init manager.
Test steps:
1 $ . oe-init-build-env
2 set MACHINE and systemd as default int manager in local.conf
DISTRO_FEATURES_append = " systemd" DISTRO_FEATURES_BACKFILL_CONSIDERED += "sysvinit" VIRTUAL-RUNTIME_login_manager = "shadow-base" VIRTUAL-RUNTIME_init_manager = "systemd" VIRTUAL-RUNTIME_initscripts = "systemd-compat-units" MACHINE ?= "genericx86-64"
3 bitbake core-image-minial
4 show ip status:
$ ip ad
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether f4:4d:30:66:fb:fd brd ff:ff:ff:ff:ff:ff
inet 128.224.162.241/23 brd 128.224.163.255 scope global dynamic enp0s25
valid_lft 13520sec preferred_lft 13520sec
inet6 fe80::f64d:30ff:fe66:fbfd/64 scope link
valid_lft forever preferred_lft forever
3: sit0@NONE: <NOARP> mtu 1480 qdisc noop qlen 1000
link/sit 0.0.0.0 brd 0.0.0.05 when connman is installed, 2 dynamic ips are allocated for enp0s25 and both work:
$ ip ad
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether f4:4d:30:66:fb:fd brd ff:ff:ff:ff:ff:ff
inet 128.224.162.241/23 brd 128.224.163.255 scope global dynamic enp0s25
valid_lft 13908sec preferred_lft 13908sec
inet 128.224.163.143/23 brd 128.224.163.255 scope global secondary enp0s25
valid_lft forever preferred_lft forever
inet6 fe80::f64d:30ff:fe66:fbfd/64 scope link
valid_lft forever preferred_lft forever
3: sit0@NONE: <NOARP> mtu 1480 qdisc noop qlen 1000
link/sit 0.0.0.0 brd 0.0.0.0Kai Kang (1):
systemd-conf: configure wired network with dhcp
meta/recipes-core/systemd/systemd-conf/dhcp.network | 5 +++++ meta/recipes-core/systemd/systemd-conf_242.bb | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 meta/recipes-core/systemd/systemd-conf/dhcp.network
--
2.20.0
PATCH 1/1 systemd-conf: configure wired network with dhcp
From: Kai Kang <[email protected]>
Add a configure file for systemd.networkd to configure wired network interfaces with dhcp. It works with common network interfaces such eth0 and eno1.
[YOCTO #13057]
--- meta/recipes-core/systemd/systemd-conf/dhcp.network | 5 +++++ meta/recipes-core/systemd/systemd-conf_242.bb | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 meta/recipes-core/systemd/systemd-conf/dhcp.network
meta/recipes-core/systemd/systemd-conf/dhcp.network new file +5 -0
@@ -0,0 +1,5 @@ +[Match] +Name=en* eth* + +[Network] +DHCP=yes
meta/recipes-core/systemd/systemd-conf_242.bb +3 -0
@@ -10,12 +10,14 @@ SRC_URI = "\ file://logind.conf \ file://system.conf \ file://system.conf-qemuall \ + file://dhcp.network \ " do_install() { install -D -m0644 ${WORKDIR}/journald.conf ${D}${systemd_unitdir}/journald.conf.d/00-${PN}.conf install -D -m0644 ${WORKDIR}/logind.conf ${D}${systemd_unitdir}/logind.conf.d/00-${PN}.conf install -D -m0644 ${WORKDIR}/system.conf ${D}${systemd_unitdir}/system.conf.d/00-${PN}.conf + install -D -m0644 ${WORKDIR}/dhcp.network ${D}${systemd_unitdir}/network/80-dhcp.network } # Based on change from YP bug 8141, OE commit 5196d7bacaef1076c361adaa2867be31759c1b52
@@ -29,4 +31,5 @@ FILES_${PN} = "\ ${systemd_unitdir}/journald.conf.d/ \ ${systemd_unitdir}/logind.conf.d/ \ ${systemd_unitdir}/system.conf.d/ \ + ${systemd_unitdir}/network/ \ "
Signature · 1 line
2.20.0
Re: [PATCH 1/1] systemd-conf: configure wired network with dhcp
Quoted 9 lines · On Mon, May 20, 2019 at 10:47 AM <[email protected]> wrote:
From: Kai Kang <[email protected]>
Add a configure file for systemd.networkd to configure wired network interfaces with dhcp. It works with common network interfaces such eth0 and eno1.
[YOCTO #13057]
I'm really not convinced about this - yes it's initially surprising, but should base packages have this kind of assumptions/policy baked into them?
--
Alex Kiernan
Re: [PATCH 1/1] systemd-conf: configure wired network with dhcp
Quoted 7 lines · Alex Kiernan
Quoted 6 lines · On Mon, May 20, 2019 at 10:47 AM <[email protected]> wrote:
From: Kai Kang <[email protected]>
Add a configure file for systemd.networkd to configure wired network interfaces with dhcp. It works with common network interfaces such eth0 and eno1.
Quoted 5 lines
Quoted 2 lines
[YOCTO #13057]
I'm really not convinced about this - yes it's initially surprising, but should base packages have this kind of assumptions/policy baked into them?
I have considered whether systemd or systemd-conf should contain such configure file. Compare to Fedora and Debian, no such kind of pre-configured network setting provided by systemd, so I added the configure file to systemd-config.
If systemd should be preferred, I'll update in v2.
Kai
Quoted 5 lines
--
Alex Kiernan
Signature · 1 line
Kai Kang
Re: [PATCH 1/1] systemd-conf: configure wired network with dhcp
Quoted 15 lines · Kang Kai
Quoted 7 lines · Alex Kiernan
Quoted 6 lines · On Mon, May 20, 2019 at 10:47 AM <[email protected]> wrote:
From: Kai Kang <[email protected]>
Add a configure file for systemd.networkd to configure wired network interfaces with dhcp. It works with common network interfaces such eth0 and eno1.
Quoted 5 lines
Quoted 2 lines
[YOCTO #13057]
I'm really not convinced about this - yes it's initially surprising, but should base packages have this kind of assumptions/policy baked into them?
Quoted 7 lines
I have considered whether systemd or systemd-conf should contain such configure file. Compare to Fedora and Debian,
no such kind of pre-configured network setting provided by systemd, so I added the configure file to systemd-config.If systemd should be preferred, I'll update in v2.
No, systemd-conf is the right place for it, since this is machine specific configuration. My question is really if this piece of configuration should exist at all in OE-Core; but I'm not totally opposed to it.
I could live with the kind of construction in meta-yoe (but with the files added to systemd-conf as you already have)
Signature · 1 line
Alex Kiernan
Re: [PATCH 1/1] systemd-conf: configure wired network with dhcp
Quoted 21 lines · Alex Kiernan
Quoted 13 lines · Kang Kai
Quoted 7 lines · Alex Kiernan
Quoted 6 lines · On Mon, May 20, 2019 at 10:47 AM <[email protected]> wrote:
From: Kai Kang <[email protected]>
Add a configure file for systemd.networkd to configure wired network interfaces with dhcp. It works with common network interfaces such eth0 and eno1.
Quoted 5 lines
Quoted 2 lines
[YOCTO #13057]
I'm really not convinced about this - yes it's initially surprising, but should base packages have this kind of assumptions/policy baked into them?
Quoted 7 lines
I have considered whether systemd or systemd-conf should contain such configure file. Compare to Fedora and Debian,
no such kind of pre-configured network setting provided by systemd, so I added the configure file to systemd-config.If systemd should be preferred, I'll update in v2.
Quoted 7 lines
No, systemd-conf is the right place for it, since this is machine specific configuration. My question is really if this piece of configuration should exist at all in OE-Core; but I'm not totally opposed to it.
I could live with the kind of construction in meta-yoe (but with the files added to systemd-conf as you already have)
The original requirement is from [Bug 13057 - No default network configuration for systemd-networkd ] which blocks to make systemd as default init manager. If add this to meta-yoe, it still no working network if no connman/networkmanager installed(but this is same as Fedora 29 and Debian 9).
Regards,
Kai
Quoted 1 line
Signature · 1 line
Kai Kang
Re: [PATCH 1/1] systemd-conf: configure wired network with dhcp
Quoted 32 lines · Kang Kai
Quoted 21 lines · Alex Kiernan
Quoted 13 lines · Kang Kai
Quoted 7 lines · Alex Kiernan
Quoted 6 lines · On Mon, May 20, 2019 at 10:47 AM <[email protected]> wrote:
From: Kai Kang <[email protected]>
Add a configure file for systemd.networkd to configure wired network interfaces with dhcp. It works with common network interfaces such eth0 and eno1.
Quoted 5 lines
Quoted 2 lines
[YOCTO #13057]
I'm really not convinced about this - yes it's initially surprising, but should base packages have this kind of assumptions/policy baked into them?
Quoted 7 lines
I have considered whether systemd or systemd-conf should contain such configure file. Compare to Fedora and Debian,
no such kind of pre-configured network setting provided by systemd, so I added the configure file to systemd-config.If systemd should be preferred, I'll update in v2.
Quoted 7 lines
No, systemd-conf is the right place for it, since this is machine specific configuration. My question is really if this piece of configuration should exist at all in OE-Core; but I'm not totally opposed to it.
I could live with the kind of construction in meta-yoe (but with the files added to systemd-conf as you already have)
Quoted 6 lines
The original requirement is from [Bug 13057 - No default network configuration for systemd-networkd ] which blocks to make systemd as default init manager. If add this to meta-yoe, it still no working network if no connman/networkmanager installed(but this is same as Fedora 29 and Debian 9).
I guess it's the requirement I'm questioning, equally you've got it systemd-conf, which is explicitly machine specific and so I'd struggle to say it shouldn't go in.
--
Alex Kiernan
Re: [PATCH 1/1] systemd-conf: configure wired network with dhcp
In reply to [email protected]Quoted 47 lines · On 5/20/19 2:46 AM, [email protected] wrote:
From: Kai Kang <[email protected]>
Add a configure file for systemd.networkd to configure wired network interfaces with dhcp. It works with common network interfaces such eth0 and eno1.
[YOCTO #13057]
Signed-off-by Kai Kang <[email protected]>--- meta/recipes-core/systemd/systemd-conf/dhcp.network | 5 +++++ meta/recipes-core/systemd/systemd-conf_242.bb | 3 +++ 2 files changed, 8 insertions(+)create mode 100644 meta/recipes-core/systemd/systemd-conf/dhcp.network
meta/recipes-core/systemd/systemd-conf/dhcp.network new file +5
-0@@ -0,0 +1,5 @@ +[Match] +Name=en* eth* + +[Network] +DHCP=yesmeta/recipes-core/systemd/systemd-conf_242.bb +2
-0@@ -10,12 +10,14 @@ SRC_URI = "\ file://logind.conf \ file://system.conf \ file://system.conf-qemuall \ + file://dhcp.network \ " do_install() { install -D -m0644 ${WORKDIR}/journald.conf ${D}${systemd_unitdir}/journald.conf.d/00-${PN}.conf install -D -m0644 ${WORKDIR}/logind.conf ${D}${systemd_unitdir}/logind.conf.d/00-${PN}.conf install -D -m0644 ${WORKDIR}/system.conf ${D}${systemd_unitdir}/system.conf.d/00-${PN}.conf + install -D -m0644 ${WORKDIR}/dhcp.network ${D}${systemd_unitdir}/network/80-dhcp.network } # Based on change from YP bug 8141, OE commit 5196d7bacaef1076c361adaa2867be31759c1b52
meta/recipes-core/systemd/systemd-conf_242.bb FILES_${PN} = "\ · line 35
Quoted 5 lines
meta/recipes-core/systemd/systemd-conf_242.bb +1
-0@@ -29,4 +31,5 @@ FILES_${PN} = "\ ${systemd_unitdir}/journald.conf.d/ \ ${systemd_unitdir}/logind.conf.d/ \ ${systemd_unitdir}/system.conf.d/ \ + ${systemd_unitdir}/network/ \ "
Please look into
https://github.com/YoeDistro/meta-yoe/tree/master/recipes-core/systemd
this also means we need to enable networkd and resolved for this to work
Re: [PATCH 1/1] systemd-conf: configure wired network with dhcp
Quoted 57 lines · Khem Raj
Quoted 49 lines · On 5/20/19 2:46 AM, [email protected] wrote:
From: Kai Kang <[email protected]>
Add a configure file for systemd.networkd to configure wired network interfaces with dhcp. It works with common network interfaces such eth0 and eno1.
[YOCTO #13057]
Signed-off-by Kai Kang <[email protected]>---
meta/recipes-core/systemd/systemd-conf/dhcp.network | 5 +++++ meta/recipes-core/systemd/systemd-conf_242.bb | 3 +++2 files changed, 8 insertions(+)create mode 100644 meta/recipes-core/systemd/systemd-conf/dhcp.network
meta/recipes-core/systemd/systemd-conf/dhcp.network new file +5
-0@@ -0,0 +1,5 @@ +[Match] +Name=en* eth* + +[Network] +DHCP=yesmeta/recipes-core/systemd/systemd-conf_242.bb +1
-0@@ -10,12 +10,14 @@ SRC_URI = "\ file://logind.conf \ file://system.conf \ file://system.conf-qemuall \ + file://dhcp.network \"
do_install(){
install -D -m0644${WORKDIR}/journald.conf${D}${systemd_unitdir}/journald.conf.d/00-${PN}.confinstall -D -m0644${WORKDIR}/logind.conf${D}${systemd_unitdir}/logind.conf.d/00-${PN}.confinstall -D -m0644${WORKDIR}/system.conf${D}${systemd_unitdir}/system.conf.d/00-${PN}.conf+ install -D -m0644 ${WORKDIR}/dhcp.network ${D}${systemd_unitdir}/network/80-dhcp.network
}
# Based on change from YP bug 8141, OE commit5196d7bacaef1076c361adaa2867be31759c1b52meta/recipes-core/systemd/systemd-conf_242.bb +1
-0@@ -29,4 +31,5 @@ FILES_${PN} = "\ ${systemd_unitdir}/journald.conf.d/ \ ${systemd_unitdir}/logind.conf.d/ \ ${systemd_unitdir}/system.conf.d/ \ + ${systemd_unitdir}/network/ \Quoted 2 lines
"
Please look into
Quoted 4 lines
https://github.com/YoeDistro/meta-yoe/tree/master/recipes-core/systemd
this also means we need to enable networkd and resolved for this to work
I checked the repo you post,
1) package config 'networkd' and 'resolved' have been involved in default package config in systemd_242.bb
2) I suspect wireless.network is not necessary. Unlike wired network, we can't predict the ap name and connect it automatically.
3) the configure file doesn't work with qemu tap mode. I'll update with it.
4) Do the configure of section [DHCP] in wired.network necessary?
[DHCP]
RouteMetric=10
ClientIdentifier=mac
Thanks.
Signature · 1 line
Kai Kang
Re: [PATCH 1/1] systemd-conf: configure wired network with dhcp
Quoted 74 lines · Kang Kai
Quoted 57 lines · Khem Raj
Quoted 49 lines · On 5/20/19 2:46 AM, [email protected] wrote:
From: Kai Kang <[email protected]>
Add a configure file for systemd.networkd to configure wired network interfaces with dhcp. It works with common network interfaces such eth0 and eno1.
[YOCTO #13057]
Signed-off-by Kai Kang <[email protected]>---
meta/recipes-core/systemd/systemd-conf/dhcp.network | 5 +++++ meta/recipes-core/systemd/systemd-conf_242.bb | 3 +++2 files changed, 8 insertions(+)create mode 100644 meta/recipes-core/systemd/systemd-conf/dhcp.network
meta/recipes-core/systemd/systemd-conf/dhcp.network new file +5
-0@@ -0,0 +1,5 @@ +[Match] +Name=en* eth* + +[Network] +DHCP=yesmeta/recipes-core/systemd/systemd-conf_242.bb +1
-0@@ -10,12 +10,14 @@ SRC_URI = "\ file://logind.conf \ file://system.conf \ file://system.conf-qemuall \ + file://dhcp.network \"
do_install(){
install -D -m0644${WORKDIR}/journald.conf${D}${systemd_unitdir}/journald.conf.d/00-${PN}.confinstall -D -m0644${WORKDIR}/logind.conf${D}${systemd_unitdir}/logind.conf.d/00-${PN}.confinstall -D -m0644${WORKDIR}/system.conf${D}${systemd_unitdir}/system.conf.d/00-${PN}.conf+ install -D -m0644 ${WORKDIR}/dhcp.network ${D}${systemd_unitdir}/network/80-dhcp.network
}
# Based on change from YP bug 8141, OE commit5196d7bacaef1076c361adaa2867be31759c1b52meta/recipes-core/systemd/systemd-conf_242.bb +1
-0@@ -29,4 +31,5 @@ FILES_${PN} = "\ ${systemd_unitdir}/journald.conf.d/ \ ${systemd_unitdir}/logind.conf.d/ \ ${systemd_unitdir}/system.conf.d/ \ + ${systemd_unitdir}/network/ \Quoted 2 lines
"
Please look into
Quoted 4 lines
https://github.com/YoeDistro/meta-yoe/tree/master/recipes-core/systemd
this also means we need to enable networkd and resolved for this to work
I checked the repo you post,
1) package config 'networkd' and 'resolved' have been involved in default package config in systemd_242.bb
2) I suspect wireless.network is not necessary. Unlike wired network, we can't predict the ap name and connect it automatically.
3) the configure file doesn't work with qemu tap mode. I'll update with it.
Quoted 6 lines
4) Do the configure of section [DHCP] in wired.network necessary?
[DHCP]
RouteMetric=10
ClientIdentifier=mac
Ignore 4). I have checked the commit message and know why.
Regards,
Kai
Quoted 4 lines
Thanks.
Signature · 1 line
Kai Kang
Re: [PATCH 1/1] systemd-conf: configure wired network with dhcp
In reply to Kang KaiQuoted 72 lines · Kang Kai
Quoted 63 lines · Khem Raj
Quoted 52 lines · On 5/20/19 2:46 AM, [email protected] wrote:
From: Kai Kang <[email protected]>
Add a configure file for systemd.networkd to configure wired network interfaces with dhcp. It works with common network interfaces such eth0 and eno1.
[YOCTO #13057]
Signed-off-by Kai Kang <[email protected]>--- meta/recipes-core/systemd/systemd-conf/dhcp.network | 5 +++++ meta/recipes-core/systemd/systemd-conf_242.bb | 3 +++ 2 files changed, 8 insertions(+)create mode 100644 meta/recipes-core/systemd/systemd-conf/dhcp.network
meta/recipes-core/systemd/systemd-conf/dhcp.network new file +5
-0@@ -0,0 +1,5 @@ +[Match] +Name=en* eth* + +[Network] +DHCP=yesmeta/recipes-core/systemd/systemd-conf_242.bb +1
-0@@ -10,12 +10,14 @@ SRC_URI = "\ file://logind.conf \ file://system.conf \ file://system.conf-qemuall \ + file://dhcp.network \ " do_install() { install -D -m0644 ${WORKDIR}/journald.conf
${D}${systemd_unitdir}/journald.conf.d/00-${PN}.confinstall -D -m0644 ${WORKDIR}/logind.conf ${D}${systemd_unitdir}/logind.conf.d/00-${PN}.conf install -D -m0644 ${WORKDIR}/system.conf
${D}${systemd_unitdir}/system.conf.d/00-${PN}.conf
+ install -D -m0644 ${WORKDIR}/dhcp.network
${D}${systemd_unitdir}/network/80-dhcp.network
}
# Based on change from YP bug 8141, OE commit5196d7bacaef1076c361adaa2867be31759c1b52meta/recipes-core/systemd/systemd-conf_242.bb FILES_${PN} = "\ · line 35
Quoted 5 lines
meta/recipes-core/systemd/systemd-conf_242.bb +1
-0@@ -29,4 +31,5 @@ FILES_${PN} = "\ ${systemd_unitdir}/journald.conf.d/ \ ${systemd_unitdir}/logind.conf.d/ \ ${systemd_unitdir}/system.conf.d/ \ + ${systemd_unitdir}/network/ \ "Please look into
Quoted 4 lines
https://github.com/YoeDistro/meta-yoe/tree/master/recipes-core/systemd
this also means we need to enable networkd and resolved for this to work
I checked the repo you post,
Quoted 8 lines
1) package config 'networkd' and 'resolved' have been involved in default package config in systemd_242.bb
2) I suspect wireless.network is not necessary. Unlike wired network, we can't predict the ap name and connect it automatically.
3) the configure file doesn't work with qemu tap mode. I'll update with it.
right your patch failed to set IP for qemux86 on my system.
Quoted 6 lines
4) Do the configure of section [DHCP] in wired.network necessary?
[DHCP]
RouteMetric=10
ClientIdentifier=mac
yes they work totally fine and also makes sure that IP is not changing all the time
for phys which happens for so many boards where you get new IP every boot
Quoted 7 lines
Thanks.
--
Kai Kang