add route called from script

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

"Per olof Ljungmark" <peo at> 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 <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 $IPADDR

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

Bill Moran
Potential Technologies

More information about the freebsd-questions mailing list