diff --git a/docs/plugins/tunnel.gre.md b/docs/plugins/tunnel.gre.md index 6028af8e10..2d7844c64f 100644 --- a/docs/plugins/tunnel.gre.md +++ b/docs/plugins/tunnel.gre.md @@ -13,6 +13,7 @@ The plugin includes Jinja2 templates for the following platforms: | FRR |✅|✅|✅| | Juniper vJunos-switch |✅|✅|✅| | Juniper vSRX |✅|✅|✅| +| Mikrotik RouterOS 7 |✅|✅|✅| | VyOS |✅|✅|✅| [^18v]: Includes Cisco IOSv, Cisco IOSvL2, Cisco CSR 1000v, Cisco Catalyst 8000v, Cisco IOS-on-Linux (IOL), and IOL Layer-2 image. diff --git a/netsim/ansible/templates/initial/routeros7.j2 b/netsim/ansible/templates/initial/routeros7.j2 index c46cbd779c..f56a3151f3 100644 --- a/netsim/ansible/templates/initial/routeros7.j2 +++ b/netsim/ansible/templates/initial/routeros7.j2 @@ -25,6 +25,12 @@ /ipv6/address add interface=loopback address={{ loopback.ipv6 }} {% endif %} + +{% for l in interfaces if l.type == 'tunnel' and l.tunnel.mode == 'gre' %} +{% set t_type = 'gre6' if l.tunnel.af == 'ipv6' else 'gre' %} +/interface/{{ t_type }} add name={{ l.ifname }} local-address={{ l.tunnel._source[l.tunnel.af] }} remote-address={{ l.tunnel._destination[l.tunnel.af] }} +{% endfor %} + {% if vlans is defined %} {% include 'routeros7.vlan.j2' %} {% endif %} @@ -34,7 +40,13 @@ {% endif %} {% for l in interfaces|default([]) %} -{% set intf_type = 'vlan' if l.type == 'svi' else 'ethernet' %} +{% if l.type == 'svi' %} +{% set intf_type = 'vlan' %} +{% elif l.type == 'tunnel' and l.tunnel.mode == 'gre' %} +{% set intf_type = 'gre6' if l.tunnel.af == 'ipv6' else 'gre' %} +{% else %} +{% set intf_type = 'ethernet' %} +{% endif %} {% if l.name is defined %} /interface/{{ intf_type }} set comment="{{ l.name }}{{ " ["+l.role+"]" if l.role is defined else "" }}" {{ l.ifname }} diff --git a/netsim/devices/routeros7.yml b/netsim/devices/routeros7.yml index e7152879ba..cd440b4b9c 100644 --- a/netsim/devices/routeros7.yml +++ b/netsim/devices/routeros7.yml @@ -5,6 +5,7 @@ support: interface_name: ether{ifindex} mgmt_if: ether1 loopback_interface_name: loopback{ifindex if ifindex else ""} +tunnel_interface_name: tunnel{ifindex} ifindex_offset: 2 libvirt: image: mikrotik/chr7 @@ -35,6 +36,8 @@ features: vpn: true ospf: true bfd: true + tunnel: + gre: [ ipv4, ipv6, vrf ] vlan: model: l3-switch svi_interface_name: "vlan{vlan}"