add route called from script

Christian Hiris 4711 at chello.at
Thu Jul 8 15:40:25 PDT 2004


On Friday 09 July 2004 00:20, Bill Moran wrote:
> "Per olof Ljungmark" <peo at intersonic.se> wrote:
> > Hi all,
> >
> > I am experimenting with openvpn-2 and so far it looks promosing. As this
> > 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 = `ifconfig | awk '<awk magic to extract the IP>'`
> route add 192.168.0.0/16 $IPADDR

If you know the number of the interface, ie tun0:

IPADDR=`ifconfig tun0 | awk '$1~/inet/&&$1!~/inet6/{print $2}'`

hth
ch

>
> I hope this is helpful, sorry I don't have a more precise answer.



-- 
Christian Hiris <4711 at chello.at> | OpenPGP KeyID 0x941B6B0B 
OpenPGP-Key at hkp://wwwkeys.eu.pgp.net and http://pgp.mit.edu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20040709/c80b778e/attachment.bin


More information about the freebsd-questions mailing list