Skip to content

Commit 5b3ef20

Browse files
authored
[VyOS] GRE tunnel implementation (#3566)
1 parent 1fe821b commit 5b3ef20

5 files changed

Lines changed: 31 additions & 0 deletions

File tree

docs/plugins/tunnel.gre.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The plugin includes Jinja2 templates for the following platforms:
1111
|--------------|:-:|:-:|:-:|
1212
| Cisco IOS/XE[^18v] ||||
1313
| FRR ||||
14+
| VyOS ||||
1415

1516
[^18v]: Includes Cisco IOSv, Cisco IOSvL2, Cisco CSR 1000v, Cisco Catalyst 8000v, Cisco IOS-on-Linux (IOL), and IOL Layer-2 image.
1617

netsim/ansible/templates/initial/vyos.j2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ set system host-name 'vyos-{{ inventory_hostname | replace("_","-") }}'
1313
{% if vlans is defined %}
1414
{% include 'vyos.vlan.j2' %}
1515
{% endif %}
16+
{% for x_dp in config|default([]) %}
17+
{% include x_dp + '/vyos.initial.j2' ignore missing %}
18+
{% endfor %}
1619

1720
{% if loopback.ipv4 is defined %}
1821
set interfaces dummy dum0 address {{ loopback.ipv4 }}
@@ -36,6 +39,8 @@ set interfaces dummy dum0 address {{ loopback.ipv6 }}
3639
{% set ns.iface_level = "dummy" %}
3740
{% elif l.ifname.startswith('bond') %}
3841
{% set ns.iface_level = "bonding" %}
42+
{% elif l.ifname.startswith('tun') %}
43+
{% set ns.iface_level = "tunnel" %}
3944
{% endif %}
4045
{#
4146
# Split interface name with vif, if needed

netsim/devices/vyos.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ description: VyOS VM/container
33
interface_name: eth{ifindex}
44
loopback_interface_name: "dum{ifindex}"
55
lag_interface_name: "bond{lag.ifindex}"
6+
tunnel_interface_name: "tun{ifindex}"
67
mgmt_if: eth0
78
libvirt:
89
image: vyos/current
@@ -81,6 +82,8 @@ features:
8182
vrf: True
8283
inter_vrf: True
8384
discard: True
85+
tunnel:
86+
gre: [ vrf ]
8487
vlan:
8588
model: l3-switch
8689
svi_interface_name: "br0.{vlan}"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{# Initial VyOS GRE tunnel implementation needs to be tackled here,
2+
otherwise it will be impossible to use the tunnel interface by other modules.
3+
#}
4+
{% for intf in netlab_interfaces if intf.tunnel.mode|default('') in ['gre'] %}
5+
6+
# In VyOS, GRE tunnels can be established over both IPv4 (encapsulation gre) and IPv6 (encapsulation ip6gre) transport networks.
7+
8+
set interfaces tunnel {{ intf.ifname }} encapsulation 'gre'
9+
{% if intf.tunnel.af == 'ipv6' %}
10+
set interfaces tunnel {{ intf.ifname }} encapsulation 'ip6gre'
11+
{% endif %}
12+
13+
set interfaces tunnel {{ intf.ifname }} source-address {{ intf.tunnel._source[intf.tunnel.af] }}
14+
set interfaces tunnel {{ intf.ifname }} remote {{ intf.tunnel._destination[intf.tunnel.af] }}
15+
16+
{% endfor %}

netsim/extra/tunnel.gre/vyos.j2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{% for intf in netlab_interfaces if intf.tunnel.mode|default('') in ['gre'] %}
2+
3+
# Source interface will also be responsible for outer VRF selection, if any.
4+
set interfaces tunnel {{ intf.ifname }} source-interface {{ intf.tunnel._source.ifname }}
5+
6+
{% endfor %}

0 commit comments

Comments
 (0)