Skip to content

Instantly share code, notes, and snippets.

@pupapaik
Created September 15, 2019 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pupapaik/a84b5b52f4afebcc16aebb1755e760fa to your computer and use it in GitHub Desktop.
Save pupapaik/a84b5b52f4afebcc16aebb1755e760fa to your computer and use it in GitHub Desktop.
if [[ $# != 1 ]]; then
echo "Usage ./sd_util <physical_intf_name>"
exit
fi
intf_name=$1
if [[ ! -d /sys/class/net/$intf_name ]]; then
echo "Interface not found, script should be run with argo stopped"
exit
fi
intf_id=`cat /sys/class/net/$intf_name/ifindex`
if [[ ! -f /run/systemd/netif/leases/$intf_id ]]; then
echo "DHCP lease file not found\n"
exit
fi
if [[ ! -f /run/systemd/netif/leases/$intf_id ]]; then
echo "DHCP file not present try after sometime\n"
exit
fi
source /run/systemd/netif/leases/$intf_id
echo "Client ID $CLIENTID"
string2=${CLIENTID:2:9}
iaid=$((16#$string2))
cat << EOF >/etc/systemd/network/10-vhost-dhcp.network
[Match]
Name=vhost0
[Network]
DHCP=yes
[DHCP]
IAID=$iaid
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment