Skip to content

Instantly share code, notes, and snippets.

@retr0h
Created October 1, 2012 02:07
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 retr0h/3809094 to your computer and use it in GitHub Desktop.
Save retr0h/3809094 to your computer and use it in GitHub Desktop.
IFACE=$( ip addr show |grep UP |grep -v lo |cut -d' ' -f2 |sed 's/://' )
MAC=$( ip addr show ${IFACE} |grep 'link/ether' |cut -d" " -f6 )
cat <<EOF > /etc/udev/rules.d/70-persistent-net.rules
# This file was generated by substructure.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="${MAC}", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
EOF
sed -i "s/${IFACE}/eth0/" /etc/network/interfaces
## Once rebooted chef kicks in, configures networking, udev, and bonding for all interfaces.
## This is just a small shim to keep eth0 up to initially reach the chef server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment