Skip to content

Instantly share code, notes, and snippets.

Created April 14, 2015 03:50
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Automatically configures netctl to use wired DHCP with a chosen interface.
interfaces=$(ip link | cut -d ":" -f 1-2 | sed 'n; d')
echo -e "Available Interfaces:\n$interfaces"
read -p "Please choose an interface: " choice
if [ "$choice" -ge 1 -a "$choice" -le $(echo "$interfaces" | wc -l) ]; then
interface=$(echo "$interfaces" | sed "${choice}q;d" | cut -d ":" -f 2 | sed 's/ //g')
sed "s/eth0/$interface/g" /etc/netctl/examples/ethernet-dhcp > /etc/netctl/ethernet-dhcp
echo "Now enabling the $interface interface..."
netctl start ethernet-dhcp
if [ $? -eq 0 ]; then
echo "Success!"
echo "An error occurred. Check the file '/etc/netctl/ethernet-dhcp' for issues."
echo "Please enter the number prefixing the desired interface."
Copy link

mohwazn commented Sep 3, 2017


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment