Skip to content

Instantly share code, notes, and snippets.

@bjoern-r
Created March 8, 2018 17:10
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 bjoern-r/f7f273bed7e3e7fa8ed11150f2763f14 to your computer and use it in GitHub Desktop.
Save bjoern-r/f7f273bed7e3e7fa8ed11150f2763f14 to your computer and use it in GitHub Desktop.
script to configure all unconfigured interfaces for dhcp and bring them up. Ubuntu-16.04
#!/bin/sh
# Author: bri
# Will add all interfaces in state DOWN to /etc/network/interfaces.d/auto.cfg
# with option dhcp
## for iface in `ls /sys/class/net/`; do
/sbin/ip -br l | awk '/DOWN/{print $1}' |
while read dev
do
echo "*** found device $dev"
printf "auto %s\niface %s inet dhcp\n\n" $dev $dev | tee -a /etc/network/interfaces.d/auto.cfg
done
echo "*** Bringing all interfaces up..."
ifup -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment