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-04-01 14:25:24 +00:00
|
|
|
% for route, rconfig in sorted(config.get('routes', {}).items()):
|
2021-01-08 15:09:59 +00:00
|
|
|
[Route]
|
2021-04-01 14:25:24 +00:00
|
|
|
% if 'via' in rconfig:
|
2021-04-01 14:31:57 +00:00
|
|
|
Gateway=${rconfig['via']}
|
2021-04-01 14:25:24 +00:00
|
|
|
% endif
|
|
|
|
Destination=${route}
|
2021-01-08 15:09:59 +00:00
|
|
|
GatewayOnlink=yes
|
2020-11-09 13:48:19 +00:00
|
|
|
|
2021-01-08 15:09:59 +00:00
|
|
|
% endfor
|
2023-09-24 16:54:47 +00:00
|
|
|
% if not config.get('dhcp', False):
|
|
|
|
% if 'gateway4' in config:
|
2020-11-09 13:48:19 +00:00
|
|
|
[Route]
|
|
|
|
Gateway=${config['gateway4']}
|
2020-11-09 15:38:35 +00:00
|
|
|
GatewayOnlink=yes
|
2020-11-09 13:48:19 +00:00
|
|
|
|
2023-09-24 16:54:47 +00:00
|
|
|
% endif
|
|
|
|
% if 'gateway6' in config:
|
2020-11-09 13:48:19 +00:00
|
|
|
[Route]
|
|
|
|
Gateway=${config['gateway6']}
|
2020-11-09 15:38:35 +00:00
|
|
|
GatewayOnlink=yes
|
2020-11-09 13:48:19 +00:00
|
|
|
|
2023-09-24 16:54:47 +00:00
|
|
|
% endif
|
2021-01-08 15:09:59 +00:00
|
|
|
% endif
|
2020-06-06 08:18:25 +00:00
|
|
|
[Network]
|
2023-09-24 16:54:47 +00:00
|
|
|
% if config.get('ipv6_accept_ra', False) or config.get('dhcp', False):
|
2022-01-04 14:47:05 +00:00
|
|
|
IPv6AcceptRA=yes
|
|
|
|
% else:
|
2020-06-06 08:18:25 +00:00
|
|
|
IPv6AcceptRA=no
|
2022-01-04 14:47:05 +00:00
|
|
|
% endif
|
2023-09-24 16:54:47 +00:00
|
|
|
% if config.get('dhcp', False):
|
|
|
|
DHCP=yes
|
|
|
|
IPv6AcceptRA=yes
|
2020-06-06 08:18:25 +00:00
|
|
|
|
2023-09-24 16:54:47 +00:00
|
|
|
[DHCPv4]
|
|
|
|
UseDomains=false
|
|
|
|
UseHostname=no
|
|
|
|
UseMTU=true
|
|
|
|
UseNTP=false
|
|
|
|
UseTimezone=no
|
|
|
|
|
|
|
|
SendHostname=no
|
|
|
|
% else:
|
|
|
|
DHCP=no
|
|
|
|
% endif
|
2020-11-13 15:29:17 +00:00
|
|
|
|
|
|
|
% for vlan in sorted(config.get('vlans', set())):
|
|
|
|
VLAN=${interface}.${vlan}
|
|
|
|
% endfor
|
2023-09-24 16:54:47 +00:00
|
|
|
% if 'activation_policy' in config:
|
|
|
|
|
|
|
|
[Link]
|
|
|
|
ActivationPolicy=${config['activation_policy']}
|
|
|
|
% endif
|