add route called from script

Bill Moran wmoran at potentialtech.com
Thu Jul 8 15:21:00 PDT 2004


"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

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

-- 
Bill Moran
Potential Technologies
http://www.potentialtech.com


More information about the freebsd-questions mailing list