Enable DHCP on enp1s0 managed by systemd-networkd.
Which .network configuration is appropriate?
Use [Match] Name=enp1s0 and [Network] DHCP=yes.
Detailed explanation
[Network]
Name=enp1s0
[Match]
DHCP=yesIncorrect. The sections for Name and DHCP are reversed.
Incorrect. The sections for Name and DHCP are reversed.
[Match]
Device=enp1s0
[DHCP]
Enabled=yesIncorrect. These are not the standard match and DHCP keys.
Incorrect. These are not the standard match and DHCP keys.
[Match]
Name=enp1s0
[Network]
DHCP=yesCorrect. It matches enp1s0 and enables DHCP.
Correct. It matches enp1s0 and enables DHCP.
[Link]
Name=enp1s0
[Network]
Address=dhcpIncorrect. Address does not accept dhcp as this value.
Incorrect. Address does not accept dhcp as this value.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' '[Match]' 'Name=enp1s0' '[Network]' 'DHCP=yes'Expected result
[Match]
Name=enp1s0
[Network]
DHCP=yesKey points
- [Match] selects device
- Name is interface
- [Network] DHCP=yes
Notes
- Environment: 設定blockの表示のみ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.