Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions netsim/ansible/templates/initial/openbsd-ifconfig.j2
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,10 @@ ifconfig {{ intf.ifname }} down
{% else %}
ifconfig {{ intf.ifname }} up
{% endif %}
{% if 'ipv6' in intf and intf.tunnel.mode|default('') in ['wireguard'] %}
# OpenBSD Wireguard does not automatically create IPv6 LLA make it ourselves
{% set _last = range(1, 65536) | random %}
{% set _lla = 'fe80::%x/64' | format(_last) %}
ifconfig {{ intf.ifname }} inet6 {{ _lla }}
{% endif %}
{% endmacro %}
5 changes: 4 additions & 1 deletion netsim/devices/openbsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ support:
level: best-effort
interface_name: vio{ifindex}
loopback_interface_name: lo{ifindex}
tunnel_interface_name: gre{ifindex}
tunnel_interface_name:
gre: gre{ifindex}
wireguard: wg{ifindex}
ifindex_offset: 1
mgmt_if: vio0
role: router
Expand Down Expand Up @@ -59,6 +61,7 @@ features:
vtep6: True
tunnel:
gre: [ ipv4 ]
wireguard: [ ipv4, ipv6 ]
libvirt:
create_template: openbsd.xml.j2
image: netlab/openbsd
Expand Down
3 changes: 3 additions & 0 deletions netsim/extra/tunnel/wireguard/openbsd.initial.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% for l in interfaces if l.type == 'tunnel' and l.tunnel.mode == 'wireguard' %}
ifconfig {{ l.ifname }} create
{% endfor %}
10 changes: 10 additions & 0 deletions netsim/extra/tunnel/wireguard/openbsd.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
# wg endpoint
{% for intf in netlab_interfaces if intf.tunnel.mode|default('') in ['wireguard'] %}
{% set dst = intf.tunnel._destination %}
{% set peer_ip = ('[' ~ dst.ipv6 ~ ']') if intf.tunnel.af == 'ipv6' else dst.ipv4 %}
{% set peer_endpoint = peer_ip ~ ':' ~ dst.listen_port %}
ifconfig {{ intf.ifname }} wgkey {{ intf.tunnel.private_key }} wgport {{ intf.tunnel.listen_port }} up
ifconfig {{ intf.ifname }} wgpeer {{ dst.public_key }} wgendpoint {{ peer_ip }} {{ dst.listen_port }} wgpka {{ intf.tunnel.persistent_keepalive }}
ifconfig {{ intf.ifname }} wgpeer {{ dst.public_key }} wgaip {{ intf.tunnel.allowed_ips.split(',') | join(' wgaip ') }}
{% endfor %}