Date: Tue, 05 Dec 2000 08:45:58 -0700 From: Wes Peters <wes@softweyr.com> To: Julian Elischer <julian@elischer.org> Cc: oscar@163.net, freebsd-hackers@freebsd.org Subject: Re: get tun0's ip from my program Message-ID: <3A2D0DB6.F67E2DE@softweyr.com> References: <3A2B8A42.09234@bjapp6.163.net> <3A2C1917.AFF94A06@elischer.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Julian Elischer wrote: > > oscar@163.net wrote: > > > > 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! > ifconfig tun0 | awk {small awk program} > > of course WHY do you want to do this? > > that may help more.. It's easier to record your addresses in some convenient form, then use that information to both set the addresses for the interface via ifconfig, and to "program" the firewall (and nat, if used). We store ours in a pair of shell scripts, which look like: /etc/extern.config: # DoBox network configuration created Tue Dec 5 08:33:49 MST 2000 extern_interface=rl0 extern_port=rl0 extern_ipaddress=0.0.0.0 extern_netmask=0.0.0.0 extern_cidr=0 extern_broadcast=0.0.0.0 extern_network=0.0.0.0 extern_configured=no /etc/intern.config: # DoBox network configuration created Tue Dec 5 08:33:49 MST 2000 intern_interface=dc0 intern_ipaddress=172.31.0.1 intern_netmask=255.255.252.0 intern_cidr=22 intern_broadcast=172.31.3.255 intern_network=172.31.0.0 intern_netpart=172.31.0 intern_domain=my.dobox These files can be sourced by scripts that (re-)create the ipfilter and ipnat rules (in our case), run ifconfig, etc. The extern config can be modified by dhclient exit hook scripts, ppp "up" configuration scripts, or by the web interface. The internal configuration can be changed some- what from the web interface, or by registering a real domain name. The internal and external interface names are decided automagically during the "first birthday" boot, by a script with intimate knowledge of what interfaces actually occur in various types of DoBox hardware. Most of the configuration files that need to be edited with this information we have renamed to file.in. We have a script, configure.net, that sources the above files and then edits each of the .in files to the actual file and restarts whatever is needed to bring the system up to date with the new configuration. -- "Where am I, and what am I doing in this handbasket?" Wes Peters Softweyr LLC wes@softweyr.com http://softweyr.com/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A2D0DB6.F67E2DE>