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

71 lines
1.2 KiB
SYSTEMD

<%
from ipaddress import ip_network
%>\
[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
[Network]
% if config.get('ipv6_accept_ra', False) or config.get('dhcp', False):
IPv6AcceptRA=yes
% else:
IPv6AcceptRA=no
% endif
% if config.get('dhcp', False):
DHCP=yes
IPv6AcceptRA=yes
[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