#!/bin/sh # ## Extracts the current IP from ifconfig. # ## usage: MY_IP=`my_ip` (with back quotes) # ## Note that if your public IP is assigned to a router like a Cisco, ## Zxyel, Cayman, or other, this will not work! # ## Hal Burgiss # ####################################################################### # #WAN_IFACE=ppp0 WAN_IFACE=eth0 #WAN Interface # make sure the interface is up to start with ... if ifconfig | grep $WAN_IFACE >/dev/null 2>&1 && ifconfig $WAN_IFACE |grep UP >/dev/null; then # extract just our desired IP ... ifconfig $WAN_IFACE | grep inet | cut -d : -f 2 | cut -d \ -f 1 exit 0 fi exit 1 #--- eof my_ip