Skip to content

Commit 905b565

Browse files
committed
fix(ddx): netplan
1 parent 33e6264 commit 905b565

File tree

1 file changed

+68
-39
lines changed

1 file changed

+68
-39
lines changed

pages/dedibox-ip-failover/how-to/configure-debian-ubuntu.mdx

Lines changed: 68 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,14 @@ This page shows you how to configure a [failover IP](/dedibox-ip-failover/concep
4141
# The primary network interface
4242
auto eth0
4343
iface eth0 inet static
44-
address 195.154.123.123
45-
netmask 255.255.255.0
46-
gateway 195.154.123.1
44+
address 195.154.123.123
45+
netmask 255.255.255.0
46+
gateway 195.154.123.1
4747
auto eth0:0
4848
iface eth0:0 inet static
4949
address ip_failover
5050
netmask 255.255.255.255
5151
```
52-
5352
<Message type="note">
5453
The interface name `eth0` may vary, depending on your OS version and system configuration. Use the `ifconfig` command to determine the name of your primary network interface.
5554
</Message>
@@ -59,43 +58,73 @@ This page shows you how to configure a [failover IP](/dedibox-ip-failover/concep
5958
ifup eth0:0
6059
```
6160

62-
## Failover IP configuration on Ubuntu
61+
## Failover IP configuration on Ubuntu (Netplan)
6362

64-
Since the release of version 18.04 (Bionic Beaver) Ubuntu has switched to [Netplan](https://netplan.io/) for the configuration of network interfaces.
63+
Since Ubuntu 18.04, Netplan has been the default network configuration system.
6564

66-
It is a YAML-based configuration system, which simplifies the configuration process.
65+
### Steps for Configuring Netplan with Failover IP
6766

68-
1. Connect to your Dedibox using SSH.
69-
2. Open the Netplan configuration file of the main interface in a text editor, for example `nano`:
70-
```
71-
sudo nano /etc/netplan/01-netcfg.yaml
72-
```
73-
3. Edit the network configuration. The IP addresses have to be written with their [CIDR notation](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation). The netmask is `/24` for the principal IP of the server and `/32` for each failover IP. Your configuration should look as in the following example:
74-
```yaml
75-
network:
76-
renderer: networkd
77-
ethernets:
78-
ensXX:
79-
addresses:
80-
- <FAILOVER_IP>/32
81-
routes:
82-
- to: 62.210.0.1
83-
- to: default
84-
via: 62.210.0.1
85-
nameservers:
86-
addresses:
87-
- 51.159.47.28
88-
- 51.159.47.26 # Replace the IP of the DNS cache server with the one located in the same physical location as your machine for optimal performance (https://www.scaleway.com/en/docs/account/reference-content/scaleway-network-information/#dns-cache-servers)
89-
search: []
90-
version: 2
91-
```
92-
<Message type="tip">
93-
* Make sure to respect the YAML standards when you edit the file, as it might not work if there is a syntax error in your configuration.
94-
* You can find an extended list of [netplan configuration examples](https://github.com/canonical/netplan/tree/main/examples) in the official Canonical Netplan repository.
95-
</Message>
96-
4. Activate the new configuration by running the following command:
97-
```
98-
sudo netplan apply
99-
```
67+
1. Disable cloud-init network configuration:
68+
```bash
69+
sudo mkdir -p /etc/cloud/cloud.cfg.d
70+
echo 'network: {config: disabled}' | sudo tee /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
71+
```
72+
2. Backup and modify the existing Netplan configuration:
73+
```bash
74+
sudo cp /etc/netplan/50-cloud-init.yaml /etc/netplan/01-myplan.yaml
75+
sudo mv /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml-backup
76+
```
77+
3. Update the Netplan Configuration
78+
Edit `/etc/netplan/01-myplan.yaml` using `nano`:
79+
```yaml
80+
network:
81+
renderer: networkd
82+
ethernets:
83+
enp5s0:
84+
critical: true
85+
dhcp-identifier: mac
86+
dhcp4: false
87+
dhcp6: false
88+
addresses:
89+
- 51.111.222.333/24 # Server main IP (/24)
90+
- 212.111.222.333/32 # Alternate IPs / IP redirects (/32)
91+
- 212.111.222.334/32
92+
- 212.111.222.335/32
93+
routes:
94+
- to: 0.0.0.0/0
95+
via: 62.210.0.1
96+
metric: 1
97+
on-link: true
98+
nameservers:
99+
addresses:
100+
- 51.159.69.156
101+
- 51.159.69.162
102+
enp6s0:
103+
dhcp4: true
104+
dhcp4-overrides:
105+
use-routes: false
106+
routes:
107+
- to: 10.88.0.0/13 # Use appropriate IP/gateway from DHCP
108+
via: 10.89.23.129
109+
version: 2
110+
```
111+
4. Run the following command to test the configuration:
112+
```bash
113+
sudo netplan try
114+
```
115+
If everything works as expected, apply the configuration:
116+
```bash
117+
sudo netplan apply
118+
```
119+
<Message type="warning">
120+
If there is an error in your configuration, it might render your network inaccessible. You may need to revert changes using KVM/IPMI access.
121+
</Message>
100122

123+
### Additional Notes
101124

125+
- Ensure that indentation and formatting are correct to avoid YAML syntax errors.
126+
- If networking issues persist, check logs using:
127+
```bash
128+
sudo journalctl -u systemd-networkd --no-pager
129+
```
130+
- More Netplan examples can be found in the [official Canonical repository](https://github.com/canonical/netplan/tree/main/examples).

0 commit comments

Comments
 (0)