Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 06 Dec 2000 01:52:00 +0000
From:      Brian Somers <brian@Awfulhak.org>
To:        oscar@163.net
Cc:        freebsd-net@FreeBSD.org, brian@Awfulhak.org
Subject:   Re: get tun0's ip from my program 
Message-ID:  <200012060152.eB61q0H00910@hak.lan.Awfulhak.org>
In-Reply-To: Message from oscar@163.net  of "Tue, 05 Dec 2000 16:59:41 %2B0800." <3A2CAE7D.25590@bjapp6.163.net> 

next in thread | previous in thread | raw e-mail | index | archive | help
> I want to get tun0's two ip addresses.
> and add ipfw rules to system at my program.
> How can I do it?is there a function? or 
> have document describe it. someone please tell me!
> thank you!

If you're using ppp, you can call a script with the primary interface 
address from ppp.linkup like this:

MYADDR:
  !bg myscript MYADDR

There's no way to get your hands on any secondary IP numbers though... 
unless you do something like

MYADDR:
  !bg myscript INTERFACE

and then have a script that does something like

#! /bin/sh

ips=`ifconfig $1 | sed -n 's/ *inet \([^ ]*\) .*/\1/p'`
.....

If you're doing this from a program, have a look at the code in 
ppp/iface.c to see how ppp does it.

> oscar
> oscar@163.net

-- 
Brian <brian@Awfulhak.org>                        <brian@[uk.]FreeBSD.org>
      <http://www.Awfulhak.org>;                   <brian@[uk.]OpenBSD.org>
Don't _EVER_ lose your sense of humour !




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




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