delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/04/21/16:46:14

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <01da01c427e1$9dd085b0$66fda287@docbill002>
From: "Bill C. Riemers" <cygwin AT docbill DOT net>
To: "Hannu E K Nevalainen" <garbage_collector AT telia DOT com>, <cygwin AT cygwin DOT com>
References: <NGBBLLIAMFLGJEOAJCCEAEFEDKAA DOT garbage_collector AT telia DOT com>
Subject: Re: how to get IP with a shell command?
Date: Wed, 21 Apr 2004 16:45:13 -0400
MIME-Version: 1.0
X-IsSubscribed: yes

> 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019