modules: misc: Improvements on ip address setting
This commit is contained in:
@@ -61,14 +61,15 @@ Name=${dev}
|
|||||||
}
|
}
|
||||||
|
|
||||||
# network_manager_static sets up a static ip address with network manager.
|
# network_manager_static sets up a static ip address with network manager.
|
||||||
# NOTE: to see what it's using run: nmcli -f name,uuid,filename connection
|
# NOTE: To see what it's using run: `nmcli -f name,uuid,filename connection`.
|
||||||
class network_manager_static($st) {
|
class network_manager_static($st) {
|
||||||
$uuid = $st->uuid || "" # 01234567-89ab-cdef-0123-456789abcdef
|
$uuid = $st->uuid || "" # 01234567-89ab-cdef-0123-456789abcdef
|
||||||
|
$mac = $st->mac || ""
|
||||||
$dev = $st->dev || "eth0"
|
$dev = $st->dev || "eth0"
|
||||||
$cidr = $st->cidr # cidr
|
$cidr = $st->cidr # cidr
|
||||||
$ip = net.cidr_to_ip($cidr)
|
$ip = net.cidr_to_ip($cidr)
|
||||||
$prefix = net.cidr_to_prefix($cidr)
|
$prefix = net.cidr_to_prefix($cidr)
|
||||||
$router = $st->router
|
$router = $st->router || ""
|
||||||
$dns = $st->dns || "8.8.8.8"
|
$dns = $st->dns || "8.8.8.8"
|
||||||
|
|
||||||
$tmpl =
|
$tmpl =
|
||||||
@@ -80,13 +81,23 @@ uuid=${uuid}
|
|||||||
{{ end -}}
|
{{ end -}}
|
||||||
type=ethernet
|
type=ethernet
|
||||||
interface-name=${dev}
|
interface-name=${dev}
|
||||||
|
autoconnect=true
|
||||||
|
|
||||||
[ipv4]
|
[ipv4]
|
||||||
|
{{ if .router -}}
|
||||||
address1=${ip}/${prefix},${router}
|
address1=${ip}/${prefix},${router}
|
||||||
|
{{ else -}}
|
||||||
|
address1=${ip}/${prefix}
|
||||||
|
{{ end -}}
|
||||||
dns=${dns};
|
dns=${dns};
|
||||||
dns-search=
|
dns-search=
|
||||||
may-fail=false
|
may-fail=false
|
||||||
method=manual
|
method=manual
|
||||||
|
|
||||||
|
[ethernet]
|
||||||
|
{{ if .mac -}}
|
||||||
|
mac-address=${mac}
|
||||||
|
{{ end -}}
|
||||||
"
|
"
|
||||||
|
|
||||||
$args = struct{
|
$args = struct{
|
||||||
|
|||||||
Reference in New Issue
Block a user