Skip to content

Commit 0763487

Browse files
authored
Configure network-mode for clab nodes (ipspace#2735)
* Standard way configure network-mode for clab nodes * Skip provisioning eth0 when clab.network-mode=='none' * Explain why we'd need 'network-mode: none' and add integration test
1 parent 025e22e commit 0763487

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

docs/labs/clab.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ In multi-provider topologies, set the **uplink** parameter only for the primary
145145

146146
You can change a device management interface's IPv4/IPv6 address with the **mgmt.ipv4**/**mgmt.ipv6** node parameter *as long as the specified IPv4/IPv6 address is within the subnet specified in the **addressing.mgmt** pool*. However, it is recommended to use the **addressing.mgmt** pool **ipv4**/**ipv6**/**start** parameters to adjust the address range used for management IP addresses and rely on *netlab* to assign management IP addresses to containers based on [device node ID](node-augment).
147147

148+
You can also set the **clab.network-mode** node parameter to *none* to disconnect a container from the management network. Use this setting in very large topologies (more than 1000 devices) to disconnect devices that don't run an SSH server from the management Linux bridge as a workaround for the *no more than 1024 interfaces per Linux bridge* limitation of the Linux kernel.
149+
148150
(clab-port-forwarding)=
149151
### Port Forwarding
150152

@@ -364,6 +366,7 @@ You can also change these *containerlab* parameters:
364366
* **clab.cmd** to [change the command of a container image](https://containerlab.dev/manual/nodes/#cmd).
365367
* **clab.startup-delay** to make certain node(s) [boot/start later than others](https://containerlab.dev/manual/nodes/#startup-delay) (amount in seconds)
366368
* **clab.restart-policy** to set the [container restart policy](https://containerlab.dev/manual/nodes/#restart-policy)
369+
* **clab.network-mode** to set the [network-mode](https://containerlab.dev/manual/nodes/#network-mode)
367370

368371
```{warning}
369372
String values (for example, the command to execute specified in **clab.cmd**) are put into single quotes when written into the `clab.yml` containerlab configuration file. Ensure you're not using single quotes in your command line.

netsim/ansible/templates/initial/frr.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ else
5050
apt-get update -qq && apt-get install -qq frr frr-pythontools bridge-utils ethtool
5151
fi
5252
{% else %}
53-
{% if netlab_mgmt_vrf|default(False) %}
53+
{% if netlab_mgmt_vrf|default(False) and clab['network-mode']|default('')!='none' %}
5454
#
5555
# Get the current next hop for the default route
5656
#

netsim/providers/clab.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ attributes:
4646
runtime: str
4747
startup-delay: int
4848
restart-policy: str
49+
network-mode: str
4950
interface:
5051
name: str
5152
link:

netsim/templates/provider/clab/clab.j2

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,16 @@ topology:
1717
{% for name,n in nodes.items() if not (n.unmanaged|default(False)) %}
1818
{% set clab = n.clab|default({}) %}
1919
{{ name }}:
20-
{% if n.mgmt.ipv4 is defined %}
21-
mgmt-ipv4: {{ n.mgmt.ipv4 }}
20+
{% if 'network-mode' in clab %}
21+
network-mode: {{ clab['network-mode'] }}
2222
{% endif %}
23-
{% if n.mgmt.ipv6 is defined %}
23+
{% if 'network-mode' not in clab or clab['network-mode'] != 'none' %}
24+
{% if n.mgmt.ipv4 is defined %}
25+
mgmt-ipv4: {{ n.mgmt.ipv4 }}
26+
{% endif %}
27+
{% if n.mgmt.ipv6 is defined %}
2428
mgmt-ipv6: {{ n.mgmt.ipv6 }}
29+
{% endif %}
2530
{% endif %}
2631
{% set kind = clab.kind | default(n.device) %}
2732
kind: {{ kind }}

tests/platform-integration/clab/02-mac-ip.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
message: |
22
Tests containers with custom management IP addresses and checks that netlab
3-
can successfully configure them.
3+
can successfully configure them. It also checks the configuration of containers
4+
disconnected from the management network.
45
56
provider: clab
67
defaults.device: eos
78
module: [ ospf ]
8-
ospf.timers.hello: 1
9+
ospf.timers:
10+
hello: 1
11+
dead: 4
12+
913
defaults.multilab.change.addressing.mgmt.ipv4: '192.42.42.0/24'
1014
addressing.mgmt.ipv4: '192.42.42.0/24'
1115

@@ -18,11 +22,14 @@ nodes:
1822
mgmt:
1923
mac: 0A:4F:A9:02:00:01
2024
ipv4: 192.42.42.207
25+
r3:
26+
device: frr
27+
clab.network-mode: none
2128

22-
links: [ r1-r2 ]
29+
links: [ r1-r2, r2-r3 ]
2330

2431
validate:
2532
adj:
2633
plugin: ospf_neighbor(nodes.r2.ospf.router_id)
2734
wait: 15
28-
nodes: [ r1 ]
35+
nodes: [ r1, r3 ]

0 commit comments

Comments
 (0)