This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: how to get IP with a shell command?


> The ipconfig stuff isn't much more reliable, depending on your setup.
> I always have TWO IP's when my PPP/ISDN is up:
>
> $ ipconfig /all

You could try using the "route print" command as well.  i.e. Maybe something
like:

route print |expand |sed -n -e "s,.* $(route print|expand|sed -n -e
's,[.],[.],g' -e 's,^Default Gateway: *,,p')  *\([0-9][0-9.]*\)
*[0-9][0-9]*,\\1,p"

But if you are behind a NAT, that probably won't give you what you really
want either...

A more elegant solution is to use dynamic dns.  For example I use the
following script run from my crontab:

#!/bin/sh
cd /tmp;exec wget --delete-after
http://freedns.afraid.org/dynamic/update.php?KSD1ADSFLIjkseS11Dc=

This automatically updates a dynamic DNS on afraid.org.  Then even when I'm
connected via WIFI across two separate NAT routers, I can still use my
dynamic DNS name.

                                  Bill




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]