New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Get your IP address


Post Reply New Thread Subscribe

 
Thread Tools
gatorparrots
Guest
 
Posts: n/a

If you are in a DHCP situation and find your IP address frequently changing, here is an easy way to determine it:
ipconfig getifaddr en0
and an alternate (albeit more convoluted method):
ifconfig en0 inet | grep 'inet ' | awk ' { print $2 } '

If you are behind a router and need your external IP address, issue this command:
wget -q -O /dev/stdout http://checkip.dyndns.org/ | grep 'Current IP Address: ' | awk ' { print $4 } '
(Of course, you would have to have wget installed in order for this to work.)

Here is a shell script for checking your IP address and logging the results to a file:
Code:
#!/bin/sh
#initialize variable
IP=`wget -q -O /dev/stdout <a href='http://checkip.dyndns.org/' target='_blank'>http://checkip.dyndns.org/</a> | grep 'Current IP Address: ' | awk ' { print $4 } '`
# prints current IP to shell
echo $IP
#log it
date >> /private/var/log/ip.log
echo $IP >> /private/var/log/ip.log
This script could be added to your crontab in order to check your IP address periodically and log the results to a file.
QUOTE Thanks
zoe77
Guest
 
Posts: n/a

the wget on http://checkip.dyndns.org/ doesn't seem to work anymore ... did the format change or something?
QUOTE Thanks
Graphite

 
Graphite's Avatar
 
Member Since: Feb 25, 2003
Location: Tropical Island, Jealous?
Posts: 5,279
Graphite has much to be proud ofGraphite has much to be proud ofGraphite has much to be proud ofGraphite has much to be proud ofGraphite has much to be proud ofGraphite has much to be proud ofGraphite has much to be proud ofGraphite has much to be proud ofGraphite has much to be proud of
Mac Specs: MacPro 3.0Ghz 16GB RAM, 4x256 Vid, 30''cinema display

Graphite is offline
this thread is over a year old... i almost forgot gatorparrots existed.. theres a few otherways, if you need to find it, PM and ill show u a lil thing i came across, ide post it but it may scare a few people.
QUOTE Thanks
zoe77
Guest
 
Posts: n/a

thanks Graphite... i'm behind a router so the wget method would suit me best.
QUOTE Thanks
StarManta
Guest
 
Posts: n/a

www.whatismyip.com
QUOTE Thanks
zoe77
Guest
 
Posts: n/a

Quote:
Originally Posted by StarManta
weird this site is giving me a different IP address...
QUOTE Thanks
gatorparrots
Guest
 
Posts: n/a

Lately, I've been using this code to obtain my external IP address:
Code:
curl -s http://www.showmyip.com/simple/ | awk '{print $1}'
However, if you have a Linksys BEFSR-series router, the following code is better for scripting purposes, as it obtains results in about half the time:
Code:
/usr/bin/curl --connect-timeout 5  -s \
           http://:$PASSWORD@$ROUTERIP/Status.htm  | \
           sed -e 's/^.*IP Address://'              | \
           sed -e 's/=2>/\\
/'                                                  | \
           sed -e '1 d'                             | \
           sed -e 's/<.*//'
QUOTE Thanks
witeshark

 
witeshark's Avatar
 
Member Since: Mar 09, 2004
Location: Miami FL
Posts: 2,860
witeshark will become famous soon enough
Mac Specs: G4 1Ghz OS X 10.4.7

witeshark is offline
You can also get it by running sheilds up to compare...
QUOTE Thanks

Post Reply New Thread Subscribe


« mounting drives from a terminal | irc »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Importing old address book into new RobinHope Switcher Hangout 0 12-31-2004 02:07 PM
MAC Address? SamR Internet, Networking, and Wireless 2 12-21-2004 11:26 AM
IP Address for VPC XP in Company LAN billitone OS X - Operating System 0 06-08-2004 08:35 PM
Importing .vcf from Panther Address Book to PC Outlook? VanDrakes OS X - Operating System 2 12-30-2003 11:19 PM
Apple to address Jaguar security problems Murlyn OS X - Operating System 3 10-31-2003 05:41 PM

All times are GMT -4. The time now is 07:38 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?