From: Michael Tremer Date: Sat, 30 Jun 2018 18:40:31 +0000 (+0100) Subject: AWS: Rename all interfaces when booting up X-Git-Tag: v2.21-core123~108 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c7141f04791dc1c3bf6799e260497be614201a75;p=ipfire-2.x.git AWS: Rename all interfaces when booting up Signed-off-by: Michael Tremer --- diff --git a/src/initscripts/helper/aws-setup b/src/initscripts/helper/aws-setup index d86ab7d397..334f3e4be1 100644 --- a/src/initscripts/helper/aws-setup +++ b/src/initscripts/helper/aws-setup @@ -47,6 +47,22 @@ prefix2netmask() { to_address "$(( netmask ^ 0xffffffff ))" } +find_interface() { + local mac="${1}" + + local path + for path in /sys/class/net/*; do + local address="$(<${path}/address)" + + if [ "${mac}" = "${address}" ]; then + basename "${path}" + return 0 + fi + done + + return 1 +} + import_aws_configuration() { local instance_id="$(get instance-id)" @@ -104,6 +120,8 @@ import_aws_configuration() { case "${device_number}" in # RED 0) + local interface_name="red0" + # The gateway is always the first IP address in the subnet local gateway="$(to_address $(( netaddress_num + 1 )))" @@ -113,7 +131,7 @@ import_aws_configuration() { ( echo "RED_TYPE=STATIC" - echo "RED_DEV=red0" + echo "RED_DEV=${interface_name}" echo "RED_MACADDR=${mac}" echo "RED_DESCRIPTION='${interface_id}'" echo "RED_ADDRESS=${ipv4_address}" @@ -133,8 +151,10 @@ import_aws_configuration() { # GREEN 1) + local interface_name="green0" + ( - echo "GREEN_DEV=green0" + echo "GREEN_DEV=${interface_name}" echo "GREEN_MACADDR=${mac}" echo "GREEN_DESCRIPTION='${interface_id}'" echo "GREEN_ADDRESS=${ipv4_address}" @@ -146,10 +166,11 @@ import_aws_configuration() { # ORANGE 2) + local interface_name="orange0" config_type=2 ( - echo "ORANGE_DEV=orange0" + echo "ORANGE_DEV=${interface_name}" echo "ORANGE_MACADDR=${mac}" echo "ORANGE_DESCRIPTION='${interface_id}'" echo "ORANGE_ADDRESS=${ipv4_address}" @@ -159,6 +180,14 @@ import_aws_configuration() { ) >> /var/ipfire/ethernet/settings ;; esac + + # Rename interface + local interface="$(find_interface "${mac}")" + + if [ -n "${interface}" ] && [ -n "${interface_name}" ]; then + ip link set "${interface}" down + ip link set "${interface}" name "${interface_name}" + fi done # Save CONFIG_TYPE