blob: 861a92834d5d86b39298019511a6bd75a4f272e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
---
title: Static addressing with systemd-networkd
description: Dual IPv4 and IPv6 configuration
date: 2025-03-04
tags:
- systemd
---
## Introduction
I like to keep up with what established operating systems or Linux distributions
are doing even though I am not using them all everyday. While trying out
OpenSUSE again recently, I gave a first try ever to using `systemd-networkd`.
## Configuration
Here is an example of how to configure your network statically with
`systemd-networkd`. The quirk is that there is no way to specify two `Gateway`
attributes in a `Network` block. Since you can have multiple `Address` blocks,
this is an inconsistency that required some reading of the manual before it
clicked.
Here is what ended up working for my `/etc/systemd/network/20-wired.network`:
``` ini
[Match]
MACAddress=fa:16:3e:82:71:b7
[Network]
Address=37.187.244.19/32
Address=2001:41d0:401:3100::fd5/64
DNS=1.1.1.1
[Route]
Destination=0.0.0.0/0
Gateway=37.187.244.1
GatewayOnLink=yes
Metric=10
[Route]
Destination=::/0
Gateway=2001:41d0:401:3100::1
Metric=10
```
The `GatewayOnLink` attribute might not be needed for you. I am using it because
this is an OVH box and this provider likes to reduce instances chatter by
issuing `/32` netmasks on DHCP. Though I could use a more standard netmask in
this static configuration, I choose to respect their preference.
## Conclusion
In the end `systemd-networkd` works well and I have no complaints other than
this quirkiness.
|