Date: Fri, 9 Jul 2004 08:40:23 -0600 From: Nathan Kinkade <nkinkade@ub.edu.bz> To: peter@bgnett.no Cc: freebsd-questions@freebsd.org Subject: Re: add route called from script Message-ID: <20040709144023.GH24348@gentoo-npk.bmp.ub> In-Reply-To: <200407090040.01913.4711@chello.at> References: <40EDBCC7.8010007@intersonic.se> <20040708182058.0419994a.wmoran@potentialtech.com> <200407090040.01913.4711@chello.at>
next in thread | previous in thread | raw e-mail | index | archive | help
--Lvl7PYhWQWN8QmIZ Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 09, 2004 at 12:39:47AM +0200, Christian Hiris wrote: > On Friday 09 July 2004 00:20, Bill Moran wrote: > > "Per olof Ljungmark" <peo@intersonic.se> wrote: > > > Hi all, > > > > > > I am experimenting with openvpn-2 and so far it looks promosing. As t= his > > > version of openvpn can assign client addresses similar to dhcp, I need > > > to find out how to assign a route from a script, like (this is the > > > client end, running FreeBSD): > > > > > > [simplifed example] > > > #!/bin/sh > > > openvpn --daemon --config my-vpn.conf > > > route add 192.168.0.0/16 <adress from tun{if} here> > > > > I'm no guru for either of these commands, but I'm guessing this is a > > canonical job for sed and/or awk. Something like: > > > > IPADDR =3D `ifconfig | awk '<awk magic to extract the IP>'` > > route add 192.168.0.0/16 $IPADDR >=20 > If you know the number of the interface, ie tun0: >=20 > IPADDR=3D`ifconfig tun0 | awk '$1~/inet/&&$1!~/inet6/{print $2}'` >=20 > hth > ch >=20 > > > > I hope this is helpful, sorry I don't have a more precise answer. One other way might be: IPADDR=3D$(ifconfig tun0 | grep 'inet' | cut -d ' ' -f 2) route add 192.168.0.0/16 ${IPADDR} But as Christian mentioned, this assumes you know the tun interface number. Nathan --=20 PGP Public Key: pgp.mit.edu:11371/pks/lookup?op=3Dget&search=3D0xD8527E49 --Lvl7PYhWQWN8QmIZ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFA7q5XO0ZIEthSfkkRAm5qAKDi3moTZYIhabAqV7vOfL3lWwT6iACfbtcz Y///TsprBPxekQCHm8eAyNg= =DziA -----END PGP SIGNATURE----- --Lvl7PYhWQWN8QmIZ--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040709144023.GH24348>