Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 05 Dec 2000 09:12:25 
From:      "Aaron Hill" <hillaa@hotmail.com>
To:        oscar@163.net, freebsd-net@freebsd.org
Subject:   Re: get tun0's ip from my program
Message-ID:  <F101Gj03oHMwVN7miR900005bd7@hotmail.com>

next 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!

I found a good example of modifying the rc.firewall file at...

http://people.freebsd.org/~jmb/PPPoE.configuration

... and modified it for my needs. In particular here's how the IP address 
for the tun0 interface is detected...

red_if="tun0"
red=`ifconfig ${red_if} | grep netmask | cut -f 2  -d  ' ' | tail -1`

Next the red_if and red objects are referenced in the firewall configuration 
with the following kind of line...

${fwcmd} add 100 deny log all from ${red} to any in recv ${red_if}


So if you need to pull the two IP addresses from tun0 I'm sure you could 
make two objects like red_ip1 and red_ip2, then pull the relevant IP address 
for each one with different uses of the head and tail utilities with the 
above commands.

Check out the above mentioned web site for a more complete picture of how to 
modify /etc/rc.firewall and how to execute it.

I hope that helps.

Aaron Hill



_____________________________________________________________________________________
Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.com



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?F101Gj03oHMwVN7miR900005bd7>