Author Topic: Check IP shell script  (Read 14379 times)

littleman

  • Administrator
  • Hero Member
  • *****
  • Posts: 6558
    • View Profile
Check IP shell script
« on: May 28, 2011, 02:05:06 AM »
Being a paranoid type I like to change my IP around a lot.  Fortunately I'm on a dynamic setup so getting a new IP is as simple as restarting the DSL modem.  I find it more convenient to call a script to check my IP than to use a web browser, so I use this script

Code: [Select]
#!/bin/bash
wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
exit 0

Just save the script say as "myip.sh", and then do a "chmod +x myip.sh" to make it executable.  Then just call it by typing "./myip.sh" if you save it in your home directory.  Alternatively, you could save it in /usr/bin, or /usr/local/bin/ and then just call it as "myip.sh" in a term window.