Skip to content

Commit 1c8bd5c

Browse files
committed
post: Static IPv6 playground blog
Signed-off-by: Edward Haas <edwardh@redhat.com>
1 parent 2a7fd9b commit 1c8bd5c

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
---
2+
title: "Static IPv6 Playground"
3+
date: 2020-05-03
4+
categories:
5+
- blog
6+
tags:
7+
- ipv6
8+
---
9+
10+
This post is all about setting up an IPv6 enviorment for learning and testing
11+
of varios setups and scenarios.
12+
13+
We will use network namespaces for our setup and proceed to define static
14+
IP addresses.
15+
(we will cover dynamic IP addresses in a following post)
16+
17+
## Basic Setup
18+
In order to prepare the ground for our IPv6 playground, we will use network
19+
namespaces to simulate different network stacks.
20+
A network namespace is an isolated network stack that includes interfaces,
21+
ip addresses and routes.
22+
23+
Throught this post, we will use the `ip` command which is part of the
24+
[iproute2](https://wiki.linuxfoundation.org/networking/iproute2) utilities.
25+
26+
### Namespace creation
27+
For our setup, we will use two namespaces: red & blue.
28+
29+
Lets create our two namespaces:
30+
```
31+
sudo ip netns add red
32+
sudo ip netns add blue
33+
```
34+
Each namespace is created with a loopback interface which requires an explicit
35+
enablement:
36+
```
37+
sudo ip netns exec red ip link set lo up
38+
sudo ip netns exec blue ip link set lo up
39+
```
40+
41+
### L2 connectivity (the veth)
42+
In order to enable connectivity between the two namespaces, we will use a
43+
veth interface. A veth interface type comes always in pairs, anything that
44+
ingress one edge, egress the other edge and vice versa. It provides a L2 local
45+
connectivity between the peers.
46+
47+
We will create the veth interface at the root namespace and then place each
48+
peer in one of the namespaces.
49+
50+
Lets create the veth interface (and enable its links):
51+
```
52+
sudo ip link add veth00 type veth peer name veth10
53+
sudo ip link set veth00 up
54+
sudo ip link set veth10 up
55+
```
56+
And place each in the relevant namespace:
57+
```
58+
sudo ip link set dev veth00 netns red
59+
sudo ip link set dev veth10 netns blue
60+
```
61+
62+
At this point, assuming that IPv6 is enabled on the host, each namespace
63+
should show a loopback interface and another veth type interface which
64+
has a [link-local IPv6 address](https://tools.ietf.org/html/rfc4291#page-11).
65+
66+
Lets check the interfaces and their addresses:
67+
```
68+
$ sudo ip netns exec red ip addr
69+
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 state UNKNOWN
70+
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
71+
inet 127.0.0.1/8 scope host lo
72+
valid_lft forever preferred_lft forever
73+
inet6 ::1/128 scope host
74+
valid_lft forever preferred_lft forever
75+
181: veth00@if180: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP
76+
link/ether 92:3a:37:75:36:40 brd ff:ff:ff:ff:ff:ff link-netnsid 1
77+
inet6 fe80::903a:37ff:fe75:3640/64 scope link
78+
valid_lft forever preferred_lft forever
79+
```
80+
```
81+
$ sudo ip netns exec blue ip addr
82+
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 state UNKNOWN
83+
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
84+
inet 127.0.0.1/8 scope host lo
85+
valid_lft forever preferred_lft forever
86+
inet6 ::1/128 scope host
87+
valid_lft forever preferred_lft forever
88+
180: veth10@if181: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP
89+
link/ether 8e:6a:6b:83:93:ea brd ff:ff:ff:ff:ff:ff link-netnsid 0
90+
inet6 fe80::8c6a:6bff:fe83:93ea/64 scope link
91+
valid_lft forever preferred_lft forever
92+
```
93+
94+
## L3 connectivity
95+
With the IPv6 link-local addresses in place, we can already check the
96+
connectivity between the two namespaces.
97+
98+
Using the infromation gathered in the previous `ip addr` commands, learn
99+
the link-local IPv6 address of each peer and use it in the ping command.
100+
101+
Note: As the addresses have link-local scope, a zone must be added to the
102+
destination address.
103+
A link-local address has a default subnet of 64 bits with a default network
104+
address of `fe80`. Therefore, on a node with multiple interfaces, an explicit
105+
egress interface needs to be provided in order for the packet to know through
106+
which interface to exit.
107+
See [here](https://tools.ietf.org/html/rfc4007) for more information
108+
about zones.
109+
110+
Lets run an IPv6 ping:
111+
```
112+
sudo ip netns exec red ping -6 fe80::<the-peer-last-64-bits-address>%veth00
113+
```
114+
115+
## IPv6 with global scope connectivity
116+
The previous IPv6 link-local addresses may be used to check L3 connectivity
117+
betweem two directly connected peers (i.e. interfaces connected to the same
118+
physical LAN). Routers are required not to forward link-local addresses.
119+
120+
Therefore, in order to enable IPv6 connectivity beyond the physical LAN,
121+
a global scoped address needs to be defined on the interface.
122+
Such address may be set statically or dynamically.
123+
124+
### IPv6 Global Static Address
125+
In order to enable connectivity without a router, we need both peers to be
126+
set on the same network subnet, i.e. the network prefix need to be identical
127+
for both peers and the host part needs to be unique.
128+
129+
We will use a 64 bit network subnet with a network address of `fd00`.
130+
Resulting in the following addresses:
131+
- red: `fd00::11/64`
132+
- blue: `fd00::22/64`
133+
134+
Lets define a static address for each namespace:
135+
```
136+
sudo ip netns exec red ip addr add fd00::11/64 dev veth00
137+
sudo ip netns exec blue ip addr add fd00::22/64 dev veth10
138+
```
139+
With this behind us, we can check the connectivity (without the zone part
140+
this time):
141+
```
142+
sudo ip netns exec red ping -6 fd00::22
143+
```
144+
145+
Next we will expore [dynamic IPv6](../dynamic-ipv6-playground).

0 commit comments

Comments
 (0)