Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
IF=$1
# Gets MAC address of the interface
MY_MAC_ADDR=`ip link show $IF | awk '/ether/ {print $2}'`
# Get the ID of the subnet that the interface is connected to
MY_SUBNET_ID=`curl http://169.254.169.254/latest/meta-data/network/interfaces/macs/$MY_MAC_ADDR/subnet-id 2> /dev/null`