2020-11-09 13:48:19 +00:00
|
|
|
<%
|
|
|
|
from ipaddress import ip_network
|
|
|
|
%>\
|
2020-06-06 08:18:25 +00:00
|
|
|
[Match]
|
|
|
|
Name=${interface}
|
|
|
|
|
2020-11-09 13:48:19 +00:00
|
|
|
% for addr in sorted(config.get('ips', set())):
|
|
|
|
[Address]
|
|
|
|
<%
|
|
|
|
if '/' in addr:
|
|
|
|
ip, prefix = addr.split('/')
|
|
|
|
else:
|
|
|
|
ip = addr
|
|
|
|
prefix = '32'
|
|
|
|
%>\
|
|
|
|
Address=${ip}/${prefix}
|
|
|
|
|
|
|
|
% endfor
|
2021-01-08 15:09:59 +00:00
|
|
|
% for route in config.get('routes', {}):
|
|
|
|
[Route]
|
|
|
|
Gateway=${route['via']}
|
|
|
|
Destination=${route['to']}
|
|
|
|
GatewayOnlink=yes
|
2020-11-09 13:48:19 +00:00
|
|
|
|
2021-01-08 15:09:59 +00:00
|
|
|
% endfor
|
2020-11-09 13:48:19 +00:00
|
|
|
% if 'gateway4' in config:
|
|
|
|
[Route]
|
|
|
|
Gateway=${config['gateway4']}
|
2020-11-09 15:38:35 +00:00
|
|
|
GatewayOnlink=yes
|
2020-11-09 13:48:19 +00:00
|
|
|
|
2021-01-08 15:09:59 +00:00
|
|
|
% endif
|
2020-11-09 13:48:19 +00:00
|
|
|
% if 'gateway6' in config:
|
|
|
|
[Route]
|
|
|
|
Gateway=${config['gateway6']}
|
2020-11-09 15:38:35 +00:00
|
|
|
GatewayOnlink=yes
|
2020-11-09 13:48:19 +00:00
|
|
|
|
2021-01-08 15:09:59 +00:00
|
|
|
% endif
|
2020-06-06 08:18:25 +00:00
|
|
|
[Network]
|
|
|
|
DHCP=no
|
|
|
|
IPv6AcceptRA=no
|
|
|
|
|
2020-11-09 13:48:19 +00:00
|
|
|
% if config.get('forwarding', False):
|
|
|
|
IPForward=yes
|
2020-06-06 08:18:25 +00:00
|
|
|
%endif
|
2020-11-13 15:29:17 +00:00
|
|
|
|
|
|
|
% for vlan in sorted(config.get('vlans', set())):
|
|
|
|
VLAN=${interface}.${vlan}
|
|
|
|
% endfor
|