mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 02:15:17 +00:00
Add 'auto_gateway' option
If enabled, a default route will be configured using the default gateway. If disabled, the default route will be removed. If this variable is not specified, the role will use the default behavior of the `network_provider` selected. Setting this option to `no` is equivalent to: - `DEFROUTE = no` in initscripts, or - `ipv4.never-default/ipv6.never-default yes` in nmcli Signed-off-by: Jack Adolph <jack.adolph@gmail.com>
This commit is contained in:
parent
6fdac168a9
commit
b368bce8aa
7 changed files with 409 additions and 0 deletions
|
|
@ -510,6 +510,12 @@ class IfcfgUtil:
|
|||
if ip["gateway6"] is not None:
|
||||
ifcfg["IPV6_DEFAULTGW"] = ip["gateway6"]
|
||||
|
||||
if ip["auto_gateway"] is not None:
|
||||
if ip["auto_gateway"]:
|
||||
ifcfg["DEFROUTE"] = "yes"
|
||||
else:
|
||||
ifcfg["DEFROUTE"] = "no"
|
||||
|
||||
route4 = []
|
||||
route6 = []
|
||||
for r in ip["route"]:
|
||||
|
|
@ -1056,6 +1062,15 @@ class NMUtil:
|
|||
s_ip6.set_property(
|
||||
NM.SETTING_IP_CONFIG_ROUTE_METRIC, ip["route_metric6"]
|
||||
)
|
||||
|
||||
if ip["auto_gateway"] is not None:
|
||||
if ip["auto_gateway"]:
|
||||
s_ip6.set_property(NM.SETTING_IP_CONFIG_NEVER_DEFAULT, False)
|
||||
s_ip4.set_property(NM.SETTING_IP_CONFIG_NEVER_DEFAULT, False)
|
||||
else:
|
||||
s_ip6.set_property(NM.SETTING_IP_CONFIG_NEVER_DEFAULT, True)
|
||||
s_ip4.set_property(NM.SETTING_IP_CONFIG_NEVER_DEFAULT, True)
|
||||
|
||||
for nameserver in ip["dns"]:
|
||||
if nameserver["family"] == socket.AF_INET6:
|
||||
s_ip6.add_dns(nameserver["address"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue