Skip to content

Commit 0d8391b

Browse files
authored
Merge pull request #569 from gibmat/tutorial-network-roles-vlan
Add VLAN tagging tutorial
2 parents defd94d + d975ba0 commit 0d8391b

4 files changed

Lines changed: 107 additions & 2 deletions

File tree

doc/reference/system/network.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ Be aware that changing network configuration may result in a brief period of tim
1010
IncusOS automatically configures each interface and bond as a network bridge. This allows for easy out-of-the-box configuration of bridged NICs for containers and virtual machines.
1111
```
1212

13+
## Roles
14+
15+
Each interface, bond or VLAN can be assigned one or more _roles_, which are used by IncusOS to control how the network device is used:
16+
17+
* `cluster`: The device is used for internal cluster communication
18+
* `instances`: The device should be made available for use by Incus containers or virtual machines
19+
* `management`: The device is used for management
20+
* `storage`: The device is used for network-attached storage connectivity
21+
22+
By default, the `cluster` and `management` roles will be assigned.
23+
1324
## Configuration options
1425

1526
Interfaces, bonds, and VLANs have a significant number of fields, which are largely self-descriptive and can be viewed in the [API definition](https://github.com/lxc/incus-os/blob/main/incus-osd/api/system_network.go).

doc/tutorials.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ The following tutorials demonstrate various ways to configure and use IncusOS.
44
```{toctree}
55
:maxdepth: 1
66
Expanding the "local" storage pool </tutorials/storage-expand-local-pool>
7-
Network: Directly attach instances to host network </tutorials/network-direct-attach>
7+
Directly attaching instances to host network </tutorials/network-direct-attach>
8+
Applying VLAN tagging to physical networks </tutorials/network-vlan-tagging>
89
```

doc/tutorials/network-direct-attach.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ gibmat@futurfusion:~$ incus network list
1111
+----------+--------+---------+----------------+---------------------------+----------------------------+---------+---------+
1212
```
1313

14-
However, sometimes you may want to attach a container or virtual machine directly to the host's network. This is easily accomplished by assigning the `instances` role to the appropriate interfaces or bonds.
14+
However, sometimes you may want to attach a container or virtual machine directly to the host's network. This is easily accomplished by assigning the `instances` [role](../reference/system/network.md) to the appropriate interfaces or bonds.
1515

1616
First, get the current IncusOS network configuration:
1717

@@ -81,6 +81,20 @@ gibmat@futurfusion:~$ incus network list
8181
+----------+--------+---------+----------------+---------------------------+----------------------------+---------+---------+
8282
```
8383

84+
Create a managed network using that network interface:
85+
86+
```
87+
gibmat@futurfusion:~$ incus network create enp5s0 parent=enp5s0 --type=physical
88+
gibmat@futurfusion:~$ incus network list
89+
+----------+----------+---------+----------------+---------------------------+----------------------------+---------+---------+
90+
| NAME | TYPE | MANAGED | IPV4 | IPV6 | DESCRIPTION | USED BY | STATE |
91+
+----------+----------+---------+----------------+---------------------------+----------------------------+---------+---------+
92+
| enp5s0 | physical | YES | | | | 0 | CREATED |
93+
+----------+----------+---------+----------------+---------------------------+----------------------------+---------+---------+
94+
| incusbr0 | bridge | YES | 10.89.179.1/24 | fd42:e1a1:408f:710a::1/64 | Local network bridge (NAT) | 1 | CREATED |
95+
+----------+----------+---------+----------------+---------------------------+----------------------------+---------+---------+
96+
```
97+
8498
Now, you can configure an instance to directly connect to the host's physical network:
8599

86100
```
@@ -97,3 +111,9 @@ gibmat@futurfusion:~$ incus list
97111
| debian-nat | RUNNING | 10.89.179.217 (eth0) | fd42:e1a1:408f:710a:1266:6aff:fef6:4995 (eth0) | CONTAINER | 0 |
98112
+---------------+---------+-----------------------+------------------------------------------------+-----------+-----------+
99113
```
114+
115+
You can also make this network the default for all instances:
116+
117+
```
118+
gibmat@futurfusion:~$ incus profile device set default eth0 network=enp5s0
119+
```
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Applying VLAN tagging to physical networks
2+
3+
IncusOS can assign automatic VLAN tagging for one or more VLANs to any configured interface or bond.
4+
5+
This tutorial will assume the network interface is named `enp5s0` and the VLAN ID we want to set is `1234`.
6+
7+
To assign the VLAN tagging, we need to make sure the interface is assigned both the `instances` [role](../reference/system/network.md) and that the `vlan_tags` property consists of a list of desired VLAN ID(s). This can be done by running `incus admin os system edit network` and edit the configuration like follows:
8+
9+
```
10+
config:
11+
interfaces:
12+
- addresses:
13+
- dhcp4
14+
- slaac
15+
hwaddr: 10:66:6a:d2:32:18
16+
lldp: false
17+
name: enp5s0
18+
required_for_online: "no"
19+
roles:
20+
- instances
21+
vlan_tags:
22+
- 1234
23+
```
24+
25+
After the configuration change is applied, a new unmanaged bridge will appear:
26+
27+
```
28+
gibmat@futurfusion:~$ incus network list
29+
+----------+--------+---------+-----------------+---------------------------+----------------------------+---------+---------+
30+
| NAME | TYPE | MANAGED | IPV4 | IPV6 | DESCRIPTION | USED BY | STATE |
31+
+----------+--------+---------+-----------------+---------------------------+----------------------------+---------+---------+
32+
| enp5s0 | bridge | NO | | | | 0 | |
33+
+----------+--------+---------+-----------------+---------------------------+----------------------------+---------+---------+
34+
| incusbr0 | bridge | YES | 10.148.244.1/24 | fd42:15d0:aec3:c78d::1/64 | Local network bridge (NAT) | 1 | CREATED |
35+
+----------+--------+---------+-----------------+---------------------------+----------------------------+---------+---------+
36+
37+
```
38+
39+
Create a managed network for VLAN `1234`:
40+
41+
```
42+
gibmat@futurfusion:~$ incus network create enp5s0.1234 parent=enp5s0 vlan=1234 --type=physical
43+
Network enp5s0.1234 created
44+
gibmat@futurfusion:~$ incus network list
45+
+-------------+----------+---------+-----------------+---------------------------+----------------------------+---------+---------+
46+
| NAME | TYPE | MANAGED | IPV4 | IPV6 | DESCRIPTION | USED BY | STATE |
47+
+-------------+----------+---------+-----------------+---------------------------+----------------------------+---------+---------+
48+
| enp5s0 | bridge | NO | | | | 1 | |
49+
+-------------+----------+---------+-----------------+---------------------------+----------------------------+---------+---------+
50+
| enp5s0.1234 | physical | YES | | | | 0 | CREATED |
51+
+-------------+----------+---------+-----------------+---------------------------+----------------------------+---------+---------+
52+
| incusbr0 | bridge | YES | 10.148.244.1/24 | fd42:15d0:aec3:c78d::1/64 | Local network bridge (NAT) | 1 | CREATED |
53+
+-------------+----------+---------+-----------------+---------------------------+----------------------------+---------+---------+
54+
```
55+
56+
Now, you can configure an instance to use VLAN `1234`:
57+
58+
```
59+
gibmat@futurfusion:~$ incus launch images:debian/13 debian --network enp5s0.1234
60+
Launching debian
61+
gibmat@futurfusion:~$ incus list
62+
+--------+---------+-----------------------+------------------------------------------------+-----------+-----------+
63+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
64+
+--------+---------+-----------------------+------------------------------------------------+-----------+-----------+
65+
| debian | RUNNING | 10.234.136.199 (eth0) | fd42:3cfb:8972:3990:1266:6aff:fe71:14e0 (eth0) | CONTAINER | 0 |
66+
+--------+---------+-----------------------+------------------------------------------------+-----------+-----------+
67+
```
68+
69+
You can also make this network the default for all instances:
70+
71+
```
72+
gibmat@futurfusion:~$ incus profile device set default eth0 network=enp5s0.1234
73+
```

0 commit comments

Comments
 (0)