A simple script for turning up the eth interface and get ip address via dhcp.
#Purpose: A simple bash script that turns on eth interface and acquire IP address from dhcp server.
if [ $n -ge 0 ]
ifconfig eth$n up; dhclient eth$n
#ifconfig eth$1 up; dhclient eth$1
echo “There is no eth id that is less than 0”
This script is for my ArchLinux vm, I am building it from core installation, and I think I will learn a lot of things from this experience.
ifconfig $(ifconfig -a | grep -i eth | cut -f 1 -d ‘ ‘) up; dhclient $(ifconfig -a | grep -i eth | cut -f 1 -d ‘ ‘)
This command line works only for one ethernet interface…Not sure how can I store the long command string (ifconfig -a |grep -i eth | cut -f 1 -d ‘ ‘) into a variable and use it….