La Vita è Bella

Thursday, March 03, 2005

OpenVPN

Finally, configured OpenVPN well now.

My situation is: 2 computers A & B, A is at the lab and in a subnet, B is at the dormitory. I just want A to use B's connection.

Following OpenVPN's Static Key Mini-HOWTO, I used the following configurations:

Server:

remote server.ip dev tun0
ifconfig 10.8.0.1 10.8.0.2
secret /etc/openvpn/static.key
comp-lzo
keepalive 10 60
ping-timer-rem
persist-tun
persist-key

Client:

remote server.ip
dev tun0
ifconfig 10.8.0.2 10.8.0.1
secret /etc/openvpn/static.key
comp-lzo
keepalive 10 60
ping-timer-rem
persist-tun
persist-key

And then is the routing settings. At server, I must enable ip forwarding as the following script:

#!/bin/sh
modprobe iptable_nat
iptables -t nat -A POSTROUTING -s 10.8.0.0/16 -d ! 10.8.0.0/16 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

At client, Add the original route to the server network, and add 10.8.0.1 as the gateway to all other networks:

#!/bin/sh
route add -net server.ip netmask 255.255.255.0 gw 192.168.0.251
route del default route add default gw 10.8.0.1

And then I can use OpenVPN!



tags: ,

14:41:00 by fishy - opensource - Permanent Link

Revision: 1.0/1.0, last modified on 2005-03- 4 @ 05:41.

Karma: 17 (57.94% out of 107 were positive) [+/-]

You can subscribe to RSS 2.0 feed for comments and trackbacks

Trackbacks:
There are currently no trackbacks for this item.
Use this TrackBack url to ping this item (right-click, copy link target). If your blog does not support Trackbacks you can manually add your trackback by using this form.

No comments yet

Add Comment

 

May the Force be with you. RAmen