Skip to content

Instantly share code, notes, and snippets.

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