Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Dec 1997 14:47:30 +1030
From:      Greg Lehey <grog@lemis.com>
To:        Nick Holshouser <nickh@ncnatural.com>
Cc:        "Robert J. Lynn Jr." <root@techster.dyn.ml.org>, freebsd-questions@FreeBSD.ORG
Subject:   Re: How do you get pppd to save ip to file?
Message-ID:  <19971226144730.39862@lemis.com>
In-Reply-To: <34A32812.299C@ncnatural.com>; from Nick Holshouser on Thu, Dec 25, 1997 at 10:44:18PM -0500
References:  <199712260308.DAA08994@techster.dyn.ml.org> <34A32812.299C@ncnatural.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Dec 25, 1997 at 10:44:18PM -0500, Nick Holshouser wrote:
> this works for me:
> netstat -rn | tail -1 | awk '{print $2}' >  file

That's mainly luck.  You're taking the last line of the netstat
output, but you can't rely on the netstat output to be in any
particular order.

I didn't answer this question the first time round because I didn't
understand it.  If you're just looking for the IP address of a
specific interface, such as your end of your PPP link, you could do
something like

 # ifconfig ppp0 | grep inet | awk '{print $2}' > file

Use 'tun0' instead of 'ppp0' if you're using user PPP.  If you have
more than one link, of course, this sort of breaks down.

> note: on my systems netstat nicely puts the line with my IP on the
> bottom, so tail -1 works.

Do you have a trick to ensure this?

Greg



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19971226144730.39862>