Skip to content

Instantly share code, notes, and snippets.

@maditnerd
Created December 14, 2012 13:43
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 maditnerd/4285559 to your computer and use it in GitHub Desktop.
Save maditnerd/4285559 to your computer and use it in GitHub Desktop.
#/bin/bash
interfaces=$(ifconfig |grep "Link"|awk '{print $1}')
interface=$(whiptail --inputbox "Listes des cartes reseaux\n-----------\n$interfaces" 0 0 "eth0" 3>&1 1>&2 2>&3)
ipaddress=$(ifconfig $interface|head -n2|tail -n1|awk '{print $2}'|sed -e 's/'addr:'//'|sed -e 's/'adr:'//');
netmask=$(ifconfig $interface |head -n2|tail -n1|awk '{print $4}'|sed -e 's/'Mask:'//'|sed -e 's/'Masque:'//')
broadcast=$(ifconfig $interface |head -n2|tail -n1|awk '{print $3}'|sed -e 's/'Bcast:'//')
gateway=$(route |grep "default" |awk '{ print $2 }')
ip_choice=$(whiptail --inputbox "Entrer votre adresse IP - Votre Adresse IP est actuellement :"$ipaddress 0 0 $ipaddress 3>&1 1>&2 2>&3)
clear
echo -e "Copier ceci dans /etc/network/interfaces\n\niface $interface inet static\n address $ip_choice\n netmask $netmask\n broadcast $broadcast\n gateway $gateway"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment