Skip to content

Commit 847f948

Browse files
authored
fix(ddx): netplan (#4335)
1 parent fe1f66b commit 847f948

File tree

1 file changed

+107
-76
lines changed

1 file changed

+107
-76
lines changed

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

Lines changed: 107 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -7,95 +7,126 @@ content:
77
paragraph: This page explains how to configure a Dedibox failover IP on Debian or Ubuntu Linux.
88
tags: failover-failover IP ip debian ubuntu dedibox linux
99
dates:
10-
validation: 2025-01-30
10+
validation: 2025-02-13
1111
posted: 2021-07-29
1212
categories:
1313
- dedibox-network
1414
---
1515

16-
This page shows you how to configure a [failover IP](/dedibox-ip-failover/concepts/#failover-ips) on Dedibox servers running on Debian or Ubuntu Linux.
16+
17+
This guide provides step-by-step instructions for configuring a Dedibox [failover IP](/dedibox-ip-failover/concepts/#failover-ips) on Debian and Ubuntu Linux. A failover IP is a secondary IP address that can be assigned to your server.
18+
1719

1820
<Macro id="requirements" />
1921

2022
- A Dedibox account logged into the [console](https://console.online.net)
2123
- [Created](/dedibox/how-to/order-a-server/) a Dedibox dedicated server
2224

25+
2326
## Failover IP configuration on Debian
2427

25-
<Message type="note">
26-
If you are using Ubuntu 18.04 or later, you should configure the interfaces using [Netplan](/dedibox-network/how-to/configure-network-netplan/).
27-
</Message>
28-
29-
1. Connect to your server using SSH.
30-
2. Open the network configuration file `/etc/network/interfaces` in a text editor, for example `nano`:
31-
```
32-
nano /etc/network/interfaces
33-
```
34-
3. Add the failover IP to the configuration as shown in the following example:
35-
```
36-
# This file describes the network interfaces available on your system
37-
# and how to activate them. For more information, see interfaces(5).
38-
# The loopback network interface
39-
auto lo
40-
iface lo inet loopback
41-
# The primary network interface
42-
auto eth0
43-
iface eth0 inet static
44-
address 195.154.123.123
45-
netmask 255.255.255.0
46-
gateway 195.154.123.1
47-
auto eth0:0
48-
iface eth0:0 inet static
49-
address ip_failover
50-
netmask 255.255.255.255
51-
```
52-
53-
<Message type="note">
54-
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.
55-
</Message>
56-
4. Save the file and exit the editor.
57-
5. Bring up the interface using the following command:
58-
```
59-
ifup eth0:0
60-
```
61-
62-
## Failover IP configuration on Ubuntu
63-
64-
Since the release of version 18.04 (Bionic Beaver) Ubuntu has switched to [Netplan](https://netplan.io/) for the configuration of network interfaces.
65-
66-
It is a YAML-based configuration system, which simplifies the configuration process.
67-
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:
28+
1. Connect to your server using SSH and open the network configuration file `/etc/network/interfaces` in a text editor, such as `nano`:
29+
```bash
30+
nano /etc/network/interfaces
31+
```
32+
2. Add the failover IP to the configuration as shown in the following example:
33+
```bash
34+
# This file describes the network interfaces available on your system
35+
# and how to activate them. For more information, see interfaces(5).
36+
# The loopback network interface
37+
auto lo
38+
iface lo inet loopback
39+
# The primary network interface
40+
auto eth0
41+
iface eth0 inet static
42+
address 195.154.123.123
43+
netmask 255.255.255.0
44+
gateway 195.154.123.1
45+
auto eth0:0
46+
iface eth0:0 inet static
47+
address ip_failover
48+
netmask 255.255.255.255
49+
```
50+
<Message type="note">
51+
The interface name (`eth0` in this example) may vary depending on your OS version and system configuration. Use the `ifconfig` command to determine the name of your primary network interface.
52+
</Message>
53+
54+
3. Save the file and exit the editor. Bring up the interface using the following command:
55+
```bash
56+
ifup eth0:0
57+
```
58+
59+
## Failover IP configuration on Ubuntu (Netplan)
60+
61+
Since Ubuntu 18.04, Netplan has been the default network configuration system.
62+
63+
1. Disable cloud-init network configuration to prevent conflicts with Netplan:
64+
```bash
65+
sudo mkdir -p /etc/cloud/cloud.cfg.d
66+
echo 'network: {config: disabled}' | sudo tee /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
67+
```
68+
<Message type="important">
69+
This step is necessary to prevent cloud-init from overriding the Netplan configuration.
70+
</Message>
71+
72+
2. Backup the existing Netplan configuration and create a new file:
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+
4. Edit the new Netplan configuration file `/etc/netplan/01-myplan.yaml` using `nano`:
78+
```yml
79+
network:
80+
renderer: networkd
81+
ethernets:
82+
enp5s0:
83+
critical: true
84+
dhcp-identifier: mac
85+
dhcp4: false
86+
dhcp6: false
87+
addresses:
88+
- 51.111.222.333/24 # Server main IP (/24)
89+
- 212.111.222.333/32 # Alternate IPs / IP redirects (/32)
90+
- 212.111.222.334/32
91+
- 212.111.222.335/32
92+
routes:
93+
- to: 0.0.0.0/0
94+
via: 62.210.0.1
95+
metric: 1
96+
on-link: true
97+
nameservers:
7998
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-
```
99+
- 51.159.69.156
100+
- 51.159.69.162
101+
enp6s0:
102+
dhcp4: true
103+
dhcp4-overrides:
104+
use-routes: false
105+
routes:
106+
- to: 10.88.0.0/13 # Use appropriate IP/gateway from DHCP
107+
via: 10.89.23.129
108+
version: 2
109+
```
110+
<Message type="tip">
111+
Ensure that indentation and formatting are correct to avoid YAML syntax errors.
112+
</Message>
113+
114+
5. Run the following command to test the configuration:
115+
```bash
116+
sudo netplan try
117+
```
118+
6. If everything works as expected, apply the configuration:
119+
```bash
120+
sudo netplan apply
121+
```
122+
<Message type="important">
123+
If there is an error in your configuration, it might render your network inaccessible. You may need to revert changes using [KVM/IPMI](/dedibox-kvm-over-ip/quickstart/) access.
124+
</Message>
100125

126+
## Troubleshooting
101127

128+
If you encounter issues with your network configuration, check the logs using:
129+
```bash
130+
sudo journalctl -u systemd-networkd --no-pager
131+
```
132+
You can also refer to the [official Canonical repository](https://github.com/canonical/netplan/tree/main/examples) for more Netplan examples and troubleshooting guides.

0 commit comments

Comments
 (0)