bundlewrap/bundles/systemd-networkd/files/template-iface.network

72 lines
1.2 KiB
SYSTEMD
Raw Permalink Normal View History

<%
from ipaddress import ip_network
%>\
2020-06-06 08:18:25 +00:00
[Match]
Name=${interface}
% 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
% for route, rconfig in sorted(config.get('routes', {}).items()):
[Route]
% if 'via' in rconfig:
Gateway=${rconfig['via']}
% endif
Destination=${route}
GatewayOnlink=yes
% endfor
% if not config.get('dhcp', False):
% if 'gateway4' in config:
[Route]
Gateway=${config['gateway4']}
GatewayOnlink=yes
% endif
% if 'gateway6' in config:
[Route]
Gateway=${config['gateway6']}
GatewayOnlink=yes
% endif
% endif
2020-06-06 08:18:25 +00:00
[Network]
% if config.get('ipv6_accept_ra', False) or config.get('dhcp', False):
IPv6AcceptRA=yes
% else:
2020-06-06 08:18:25 +00:00
IPv6AcceptRA=no
% endif
% if config.get('dhcp', False):
DHCP=yes
IPv6AcceptRA=yes
2020-06-06 08:18:25 +00:00
[DHCPv4]
UseDomains=false
UseHostname=no
UseMTU=true
UseNTP=false
UseTimezone=no
SendHostname=no
% else:
DHCP=no
% endif
% for vlan in sorted(config.get('vlans', set())):
VLAN=${interface}.${vlan}
% endfor
% if 'activation_policy' in config:
[Link]
ActivationPolicy=${config['activation_policy']}
% endif