Set 192.0.2.10/24 and gateway 192.0.2.1 in the [Network] section.
Which configuration is appropriate?
Use [Network] Address= for the prefix-bearing interface address and Gateway= for the next hop.
Detailed explanation
[Network]
IP=192.0.2.10
Netmask=255.255.255.0
DefaultRoute=192.0.2.1Incorrect. These are not the systemd.network keys for this configuration.
Incorrect. These are not the systemd.network keys for this configuration.
[Address]
Gateway=192.0.2.1
[Route]
Address=192.0.2.10/24Incorrect. Address and gateway are placed in the wrong sections.
Incorrect. Address and gateway are placed in the wrong sections.
[Network]
Address=192.0.2.1
Gateway=192.0.2.10/24Incorrect. The address and gateway values are swapped.
Incorrect. The address and gateway values are swapped.
[Network]
Address=192.0.2.10/24
Gateway=192.0.2.1Correct. It assigns the static address and gateway correctly.
Correct. It assigns the static address and gateway correctly.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' 'Address=192.0.2.10/24' 'Gateway=192.0.2.1'Expected result
Address=192.0.2.10/24
Gateway=192.0.2.1Key points
- Address includes prefix
- Gateway is next hop
- Same [Network] section
Notes
- Environment: 設定keyの表示のみ
- 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.