From owner-freebsd-net Tue Dec 5 17:52:58 2000 From owner-freebsd-net@FreeBSD.ORG Tue Dec 5 17:52:56 2000 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from Awfulhak.org (tun.AwfulHak.org [194.242.139.173]) by hub.freebsd.org (Postfix) with ESMTP id 7706B37B400 for ; Tue, 5 Dec 2000 17:52:37 -0800 (PST) Received: from hak.lan.Awfulhak.org (root@hak.lan.awfulhak.org [172.16.0.12]) by Awfulhak.org (8.11.1/8.11.1) with ESMTP id eB61n4M10392; Wed, 6 Dec 2000 01:49:04 GMT (envelope-from brian@hak.lan.Awfulhak.org) Received: from hak.lan.Awfulhak.org (brian@localhost [127.0.0.1]) by hak.lan.Awfulhak.org (8.11.1/8.11.1) with ESMTP id eB61q0H00910; Wed, 6 Dec 2000 01:52:00 GMT (envelope-from brian@hak.lan.Awfulhak.org) Message-Id: <200012060152.eB61q0H00910@hak.lan.Awfulhak.org> X-Mailer: exmh version 2.2 06/23/2000 with nmh-1.0.4 To: oscar@163.net Cc: freebsd-net@FreeBSD.org, brian@Awfulhak.org Subject: Re: get tun0's ip from my program In-Reply-To: Message from oscar@163.net of "Tue, 05 Dec 2000 16:59:41 +0800." <3A2CAE7D.25590@bjapp6.163.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <903.976067520.1@hak.lan.Awfulhak.org> Date: Wed, 06 Dec 2000 01:52:00 +0000 From: Brian Somers Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org > 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 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