Skip to content

Instantly share code, notes, and snippets.

@codeb2cc
Created October 29, 2012 02:50
Show Gist options
  • Save codeb2cc/3971185 to your computer and use it in GitHub Desktop.
Save codeb2cc/3971185 to your computer and use it in GitHub Desktop.
Get PPPoe IP address
#!/bin/sh
if [ `nm-tool | ack eth0 -A 5 | ack State | sed 's/ *//g' | cut -f 2 -d ':'` == "connected" ]; then
# Interface eth0 UP
:
else
# Interface eth0 DOWN. Try to restart
ifup eth0
fi
URL='http://ping.codeb2cc.com?ip='
# IP=$(curl -s "http://iframe.ip138.com/ic.asp" 2>&1 | ack '\[(.*)\]' --output '$1')
IP=$(curl -s "ifconfig.me/ip")
curl -s $URL$IP >& /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment