A collection of classes for accessing the systemd configuration files.
Only tested with Python 3.6 on Debian 9.5.
pip install sysdfiles
from sysdfiles import NetworkFile
network = NetworkFile('/etc/systemd/network/lan.network')
print(network.match_name)
print(network.match_mac_address)
network.network_dhcp = ['8.8.8.8', '8.8.4.4']
network.network_dhcp_server = True
network.dhcp_server_emit_dns = True
network.dhcp_server_dns = '192.168.0.1'
network.route_metric = 10
network.save()
Copyright © 2018 Shawn Baker using the MIT License.