This commit is contained in:
mwiegand 2021-10-10 17:15:08 +02:00
parent 42fc425173
commit 4dd42db7f2
3 changed files with 30 additions and 10 deletions

View file

@ -1,8 +1,27 @@
# defaults = {
# 'network': {
# 'external': {
# 'gateway4': '172.31.1.1',
# 'gateway6': 'fe80::1',
# },
# },
# }
from ipaddress import ip_network, ip_interface
@metadata_reactor.provides(
'systemd/units',
)
def network(metadata):
interface = ip_interface(metadata.get('network/internal/ipv4'))
network = ip_interface(f'{interface.ip}/24').network
gateway = network[1]
return {
'systemd': {
'units': {
'internal.network': {
f'Route#hetzner_gateway': {
'Destination': str(gateway),
'Scope': 'link',
},
f'Route#hetzner_network': {
'Destination': str(network),
'Gateway': str(gateway),
},
},
},
},
}

View file

@ -3,6 +3,7 @@
'groups': [
'backup',
'debian-11',
'hetzner-cloud',
],
'bundles': [
# 'steam',
@ -20,7 +21,7 @@
'network': {
'internal': {
'interface': 'ens10',
'ipv4': '10.0.10.3/24',
'ipv4': '10.0.10.3/32',
},
'external': {
'interface': 'eth0',

View file

@ -19,7 +19,7 @@
'network': {
'internal': {
'interface': 'ens10',
'ipv4': '10.0.10.2/24',
'ipv4': '10.0.10.2/32',
},
'external': {
'interface': 'eth0',