@@ -83,6 +83,12 @@ GENERAL OPTIONS
profile. If this variable is not specified, it defaults to the value
of 'Interface='.
+'MACAddress='::
+ Optional MAC address for newly created interfaces. When set to the
+ name of an existing interface, the address of that interface is used.
+ The connection types that create an interface and are able to set a
+ MAC address are +bond+, +bridge+, +dummy+, +vlan+, and +macvlan+.
+
'After=()'::
An array of profile names that should be started before this profile
is started. This is only an ordering dependency and is not intended
@@ -544,9 +550,6 @@ following are understood for connections of the `macvlan' type:
Either `bridge', `vepa', `private', or `passthru'. See *ip*(8) for
details.
-'MACAddress='::
- Optional static MAC address for the `macvlan' type link.
-
SPECIAL QUOTING RULES
---------------------
@@ -11,7 +11,7 @@ bond_up() {
return 1
fi
- interface_add bond "$Interface" "" ${Mode:+mode "$Mode"}
+ interface_add bond "$Interface" "$MACAddress" "" ${Mode:+mode "$Mode"}
bring_interface_up "$Interface"
for slave in "${BindsToInterfaces[@]}"; do
ip link set dev "$slave" master "$Interface"
@@ -11,8 +11,11 @@ bridge_up() {
report_error "Interface '$Interface' already exists and is not a bridge"
return 1
fi
+ if [[ "$MACAddress" ]]; then
+ report_error "Setting a MAC address on existing bridge interface '$Interface' is unsupported"
+ fi
else
- interface_add bridge "$Interface"
+ interface_add bridge "$Interface" "$MACAddress"
fi
for member in "${BindsToInterfaces[@]}"; do
@@ -11,7 +11,7 @@ dummy_up() {
return 1
fi
- interface_add dummy "$Interface"
+ interface_add dummy "$Interface" "$MACAddress"
bring_interface_up "$Interface"
ip_set
}
@@ -15,10 +15,7 @@ macvlan_up() {
return 1
else
bring_interface_up "$BindsToInterfaces"
- interface_add macvlan "$Interface" "$BindsToInterfaces" mode "$Mode"
- if [[ $MACAddress ]]; then
- ip link set dev "$Interface" address "$MACAddress" || return 1
- fi
+ interface_add macvlan "$Interface" "$MACAddress" "$BindsToInterfaces" mode "$Mode" || return 1
fi
ethernet_up
}
@@ -15,7 +15,7 @@ vlan_up() {
return 1
else
bring_interface_up "$BindsToInterfaces"
- interface_add vlan "$Interface" "$BindsToInterfaces" id "$VLANID"
+ interface_add vlan "$Interface" "$MACAddress" "$BindsToInterfaces" id "$VLANID"
fi
ethernet_up
@@ -20,11 +20,15 @@ is_interface() {
## Add an interface
# $1: interface type
# $2: interface name
-# $3: interface link (optional)
-# $4...: additional arguments
+# $3: interface MAC address (optional)
+# $4: interface link (optional)
+# $5...: additional type related arguments
interface_add() {
- local type="$1" name="$2" link="$3"
- do_debug ip link add ${link:+link "$link"} name "$name" type "$type" "${@:4}" $LinkOptions || return
+ local type="$1" name="$2" address="$3" link="$4"
+ if [[ -e "/sys/class/net/$address/address" ]]; then
+ address=$(< "/sys/class/net/$address/address")
+ fi
+ do_debug ip link add ${link:+link "$link"} name "$name" ${address:+address "$address"} type "$type" "${@:5}" $LinkOptions || return
load_interface_config "$name"
}