Skip to content

Commit a24ead6

Browse files
ziirishbene2k1jcirinosclwy
authored
feat(instance): new how-to configure a custom IPv6 within a given prefix (#4341)
* feat(instance): new how-to configure a custom IPv6 within a given prefix Signed-off-by: ziirish <[email protected]> * Apply suggestions from code review Co-authored-by: Jessica <[email protected]> --------- Signed-off-by: ziirish <[email protected]> Co-authored-by: Benedikt Rollik <[email protected]> Co-authored-by: Jessica <[email protected]>
1 parent c5df5e8 commit a24ead6

File tree

1 file changed

+160
-4
lines changed

1 file changed

+160
-4
lines changed

pages/instances/how-to/use-flexips.mdx

Lines changed: 160 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ meta:
55
content:
66
h1: How to use flexible IP addresses with Instances
77
paragraph: This page explains how to use flexible IP addresses with Scaleway Instances.
8-
tags: flexible-ip Instance flexible ip detach delete attach
8+
tags: flexible-ip Instance flexible ip detach delete attach ipv6
99
dates:
1010
validation: 2024-08-26
1111
posted: 2021-05-26
@@ -17,12 +17,12 @@ This page provides guidance on using [flexible IP addresses](/instances/concepts
1717

1818
When creating an Instance, you have options for network connectivity:
1919

20-
- **Flexible Routed IP addresses**: These are public IP addresses routed directly to your Instance. **Recommended.**
21-
- **Flexible NAT IP addresses (Legacy)**: Comprising a public IP address (also a flexible IP address) and a private IP address routed to your Instance via a [CG-NAT](/instances/concepts/#carrier-grade-nat-cgnat).
20+
- **Flexible routed IPv4 addresses**: public IPv4 addresses routed directly to your Instance.
21+
- **Flexible routed IPv6 addresses**: public IPv6 prefixes routed directly to your Instance.
2222

2323
Flexible IP addresses can be managed independently of any Instance. You can attach and detach them from any of your Instances and maintain multiple flexible IP addresses in your account simultaneously. They facilitate [live migration of IP addresses between your Instances](/instances/how-to/migrate-instances/).
2424

25-
You can assign up to five (5) flexible routed IP addresses to each Instance or one set of flexible NAT IP addresses.
25+
You can assign up to five (5) flexible routed IP addresses to each Instance.
2626

2727
<Message type="tip">
2828
Instances using routed public IPv4 addresses can also use flexible IPv6 addresses.
@@ -82,4 +82,160 @@ When you no longer want one of your existing flexible IP addresses, you can dele
8282

8383
The flexible IP is deleted. If it was attached to an Instance, that Instance now has no public IP address.
8484

85+
## Flexible IPv6
86+
87+
### About routed IPv6
88+
89+
Since [mid 2023](https://www.scaleway.com/en/blog/ip-mobility-removing-nat/), we built a new network stack for Scaleway Instances to enable new features. One of those is the ability to have flexible/reserved IPv6 whose main purpose is to allow to keep the same IPv6 whenever you stop/start your Instance.
90+
91+
Before routed IPs, IPv6 addresses were statically routed to the hypervisors, which means your IP changed depending on which hypervisor your Instance was running on.
92+
93+
### IPv6 prefix and SLAAC
94+
95+
Now, let's dive into the routed IPv6. Whenever you book a `routed_ipv6` IP type, you get assigned a full IPv6 prefix of 64 bits in length. According to [section 2.4](https://datatracker.ietf.org/doc/html/rfc4291#section-2.4) of the RFC4291, except for a few prefixes, anything is a Global Unicast address type. Today's [best practice](https://www.ripe.net/publications/docs/ripe-690/#4-1-1---64-prefix-from-a-dedicated-pool-of-ipv6-prefixes) is to provide a /64 prefix.
96+
97+
Another reason we decided to provide you with a /64 prefix is to be able to use [SLAAC](https://datatracker.ietf.org/doc/html/rfc4862) as the configuration mechanism. But SLAAC has been designed to work [exclusively with /64 prefixes](https://notes.networklessons.com/ipv6-prefix-length-used-for-slaac).
98+
99+
We chose SLAAC over DHCPv6 because it doesn't require any client-side configuration in most cases, allowing the feature to work with old Instances too.
100+
101+
### Limitations
102+
103+
As you may have already noticed, there are some limitations to this design that we tried to minimize.
104+
105+
The first one is that, in order not to break already deployed SDKs, or CLIs, we had to introduce a new `prefix` field to the `/ips` endpoint:
106+
107+
```
108+
{
109+
"address": null,
110+
"id": "153e451e-866b-4f58-9241-3bdbe98a0175",
111+
"ipam_id": "a81665be-0059-431f-bf44-8d7bdf1dac01",
112+
"organization": "8e214357-66e2-43ee-8898-0da03fd869e2",
113+
"prefix": "2025:bd8:911::/64",
114+
"project": "8e214357-66e2-43ee-8898-0da03fd869e2",
115+
"reverse": null,
116+
"server": null,
117+
"state": "detached",
118+
"tags": [],
119+
"type": "routed_ipv6",
120+
"zone": "fr-par-1"
121+
}
122+
```
123+
124+
On the other hand, the `/servers/<id>` endpoint provides the `public_ip` (deprecated) field and its replacement `public_ips`. This struct also contains an address field of type IP that does not accept a prefix:
125+
126+
```
127+
[
128+
{
129+
"id": "e37b038d-c5f7-4fc7-8ac2-407807f723dd",
130+
"address": "2025:bd8:911:46:dc00:ff:fe08:ab0c",
131+
"dynamic": false,
132+
"gateway": "fe80::dc00:ff:fe08:ab0c",
133+
"netmask": "64",
134+
"family": "inet6",
135+
"provisioning_mode": "slaac",
136+
"tags": [],
137+
"state": "attached",
138+
"ipam_id": "45791fdb-c576-4447-985b-19b45740714b"
139+
}
140+
]
141+
```
142+
143+
Instead, we return the SLAAC address based on the EUI-64 of the interface.
144+
145+
One consequence is that, if you move your `routed_ipv6` **prefix** to another Instance (hence, with another MAC address), the `public_ips` list will show you a **different** address because its EUI-64 will differ.
146+
147+
## Workaround
148+
149+
Since the whole /64 prefix is routed to your Instance, it is possible to define a second IPv6 address within the prefix that may be used to reach your Instance. However, this requires some custom settings.
150+
151+
In order to do that, we will use the **cloud-init** mechanism to define the second IPv6 address.
152+
153+
Let's say your prefix is: `2025:bd8:911::/64`
154+
155+
We will use the following /128 address within this range: `2025:bd8:911:a7f1::1/128`.
156+
157+
The cloud-init configuration can be uploaded with the Scaleway CLI:
158+
159+
```
160+
scw instance server update <SERVER_UUID> [email protected]
161+
```
162+
163+
### Debian >= 11 and Ubuntu >= 20.04
164+
165+
First of all, create a file with the following content:
166+
167+
```
168+
cat << EOF > ipv6-cloud-init.txt
169+
#cloud-config
170+
write_files:
171+
- path: /etc/netplan/100-ipv6-config.yaml
172+
owner: root
173+
permissions: '0400'
174+
content: |
175+
network:
176+
ethernets:
177+
ens2:
178+
addresses:
179+
- 2025:bd8:911:a7f1::1/128
180+
runcmd:
181+
- ['netplan', 'apply']
182+
EOF
183+
```
184+
185+
This cloud-init configuration file will add the `netplan` definition of a second IPv6 address within the /64 prefix (you can choose any /128 contained in your prefix). It will then apply the `netplan` configuration so the new IPv6 address becomes available.
186+
187+
### CentOS Stream 9, AlmaLinux >= 8 and RockyLinux >= 8
188+
189+
For CentOS Stream 9, AlmaLinux >= 8, and RockyLinux >= 8, you must interact with `NetworkManager` instead of `netplan`.
190+
191+
```
192+
cat << EOF > ipv6-cloud-init.txt
193+
#cloud-boothook
194+
#!/bin/sh
195+
if ! nmcli connection show | grep eth0-ipv6; then
196+
nmcli connection clone --temporary "System eth0" eth0-ipv6
197+
nmcli connection modify eth0-ipv6 +ip6 2025:bd8:911:a7f1::1/128
198+
else
199+
sleep 10
200+
fi
201+
nmcli connection up eth0-ipv6
202+
EOF
203+
```
204+
205+
### Fedora
206+
207+
Fedora also uses `NetworkManager` but with different configuration names.
208+
209+
There is also a little change between Fedora 40 and 41. The following cloud-init configuration is built for Fedora 40:
210+
211+
```
212+
cat << EOF > ipv6-cloud-init.txt
213+
#cloud-boothook
214+
#!/bin/sh
215+
if ! nmcli connection show | grep eth0-ipv6; then
216+
nmcli connection clone --temporary "cloud-init eth0" eth0-ipv6
217+
nmcli connection modify eth0-ipv6 +ip6 2025:bd8:911:a7f1::1/128
218+
else
219+
sleep 10
220+
fi
221+
nmcli connection up eth0-ipv6
222+
EOF
223+
```
224+
225+
And the following one is built for Fedora 41:
226+
227+
```
228+
cat << EOF > ipv6-cloud-init.txt
229+
#cloud-boothook
230+
#!/bin/sh
231+
if ! nmcli connection show | grep eth0-ipv6; then
232+
nmcli connection clone --temporary "cloud-init eth0" eth0-ipv6
233+
nmcli connection modify eth0-ipv6 +ip6 2025:bd8:911:a7f1::1/128
234+
else
235+
sleep 10
236+
fi
237+
nmcli connection up eth0-ipv6
238+
EOF
239+
```
240+
85241

0 commit comments

Comments
 (0)