Re: Is there a utility to get IP address from interface?
On Wed, Jun 09, 2004 at 11:08:12AM +1000, James Sinnamon wrote: Dear debian users, Is there a utility to simply return the IP address of an interface, say eth1 or ppp0? I need something that works like: $ netutil eth0 144.133.251.117 ... or is it necessary to use ifconfig something like as follows: $ ifconfig eth0 | sed ' ... ' | cut '' | awk '...' | etc 144.133.251.117 ? TIA James PS. I am doing this all in order to get ddns3 working so any pointers to useful docs would be greatly appreciated. I would just put a script in /etc/ppp/ip-up.d/. Scripts there are run once a ppp link is up, and get environment variables containing the ip address among other things. Have a look at /etc/ppp/ip-up for more information. Frank -- James Sinnamon jps at westnet com auStralia ph +61 412 319669, +61 2 95692123, +61 2 95726357 -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED] -- Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. - Brian W. Kernighan -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: Is there a utility to get IP address from interface?
Incoming from James Sinnamon: Is there a utility to simply return the IP address of an interface, say eth1 or ppp0? I need something that works like: $ netutil eth0 144.133.251.117 #!/usr/bin/perl -w use strict; my ( $ip ); open ( IFC, /sbin/ifconfig | ) or die qq($0: failed opening ifconfig pipe. $!); while( IFC ) { if ( /P\-t\-P/ ) { ( undef, $ip ) = split( /:/ ); ( $ip, undef ) = split( / /, $ip ); print STDOUT $ip; last; } } close( IFC ); -- Any technology distinguishable from magic is insufficiently advanced. (*) http://www.spots.ab.ca/~keeling - - -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: Is there a utility to get IP address from interface?
On Wed, Jun 09, 2004 at 11:08:12AM +1000, James Sinnamon wrote: Dear debian users, Is there a utility to simply return the IP address of an interface, say eth1 or ppp0? I need something that works like: $ netutil eth0 144.133.251.117 ... or is it necessary to use ifconfig something like as follows: $ ifconfig eth0 | sed ' ... ' | cut '' | awk '...' | etc 144.133.251.117 ipmasq package have command for it (but installing ipmasq have side effect of setting your system as gateway machine.) Here is /usr/sbin/ipofif command: ---x8 #!/bin/sh # # ipofifDetermines the IP address of the interface given on the # commandline export LC_ALL=C export LANG=C export LANGUAGE=C ( /sbin/ifconfig $1 | sed -n -e'/inet addr:/s/^.*inet addr:\([0-9.]*\).*$/\1/p' ) 2/dev/null true ---x8 You may do apt-get install -d ipmasq and peek into package with mc :) There are few other script you may want to use :) sed is much lighter than perl and available even when /usr is not mounted yet. Osamu -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: Is there a utility to get IP address from interface?
James Sinnamon wrote: Dear debian users, Is there a utility to simply return the IP address of an interface, say eth1 or ppp0? I need something that works like: $ netutil eth0 144.133.251.117 ... or is it necessary to use ifconfig something like as follows: $ ifconfig eth0 | sed ' ... ' | cut '' | awk '...' | etc 144.133.251.117 ? TIA James PS. I am doing this all in order to get ddns3 working so any pointers to useful docs would be greatly appreciated. This is a script one of my co-workers wrote that may help http://zwitterion.org/software/dynamic-dns-update/ -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]