Skip to content

Dynamically get network interface name in domainjoin_unix_script.go #469

@DanielTeraSky

Description

@DanielTeraSky

As part of the domain join script for Unix, there is a line where we get the interface IP address, but the interface name is hard-coded (eth0) as you can see here:

ip_address="$(ip -o -4 addr show eth0 | awk '{print $4}' | cut -d/ -f1)"

Although this works for t2 instance types, it doesn't work for t3and t3a since the network interface name has changed to ensX.

I suggest to change this line to dynamically fetch the the IP without specifying the interface name.
There are 2 options to do this:

# Option 1:
ip_address="$(hostname -I)"

# Option 2:
ip_address="$(ip -o -4 addr show $(ip route list | grep default | grep -E  'dev (\w+)' -o | awk '{print $2}') | awk '{print $4}' | cut -d/ -f1)"

This is an important fix as there is currently an issue with this script when running on newer machine types

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions