- The first thing that anyone needs to do is generate a shared-secret key that can be shared between the two peers.
Use the following command to generate this:
openvpn@mia:~/certificates> openvpn --genkey --secret temp.key
openvpn@mia:~/certificates> cat temp.key
-----BEGIN OpenVPN Static key V1-----
3e51dd78f851023b
8f90c386555f7e77
8fb104b6da7ad925
21bf4640b1fea1ed
d8122049cea29837
e1f03ce9f6456494
639bd25ea938f9d9
8c7f677c29cf4acc
2ef6608043048f7c
805a8837910092aa
660f7daa903feaba
f6768125323a56ca
2a5e04193b9c18c7
ffaf9006f3d74d0f
0d3e331d66b95b34
35dc22fe3748cd30
-----END OpenVPN Static key V1-----
- Place this secret key (temp.key) in a known location.
I usually use $HOME/certificates on all my peers. Copy this secret key in the peer's $HOME/certificates
using scp as follows:
openvpn@mia:~/certificates> scp temp.key openvpn@zidler:~/certificates
- Set up a proper configuration file on both the peers. Read the man page for openvpn to know
the different configuration options. You can leave most of these to their default values. The important ones, that
i wanted to change are shown below:
openvpn@mia:~> cat openvpn.conf
dev tun
port 5000
#comp-lzo
#ping 15
verb 3
#shaper 1000
remote 131.193.50.184
ifconfig 192.168.254.200 192.168.254.201
up /home/openvpn/bin/ip-up.sh
down /home/openvpn/bin/ip-down.sh
#Using Pre-Shared Secret Key.
secret /home/openvpn/certificates/static.key
auth MD5
cipher DES-CBC
#keysize 192
-------------------------------------------------------------------
openvpn@zidler:~> cat openvpn.conf
dev tun
port 5000
#comp-lzo
#ping 15
verb 3
#shaper 1000
remote 131.193.50.165
ifconfig 192.168.254.201 192.168.254.200
up /home/openvpn/bin/ip-up.sh
down /home/openvpn/bin/ip-down.sh
#Using Pre-Shared Secret Key.
secret /home/openvpn/certificates/static.key
auth MD5
cipher DES-CBC
#keysize 192
NOTE: Take note of the remote AA.BB.CC.DD and ifconfig 192.168.254.XX 192.168.254.YY
options. The IP Address's are reversed at the two peers. Uncomment comp-lzo if you want to use compression,
and shaper n if you want to limit the bandwidth to n Bytes/Sec.
- You can also select different ciphers (as made available by your openssl implementation). To see what
is available on your platform use the following commands:
openvpn@mia:~> openvpn --show-ciphers
--SNIP--
DES-CFB 64 bit default key (fixed)
DES-CBC 64 bit default key (fixed)
--SNIP--
Specify the selected cipher (DES-CFB, say) in the configuratoin file as cipher DES-CFB.
Only one cipher can be specified, and AFAIK there is no negotiation between the two peers.
- You can also select different MACs (as made available by your openssl implementation). To see what
is available on your platform use the following commands:
openvpn@mia:~> openvpn --show-digests
--SNIP--
MD2 128 bit digest size
MD5 128 bit digest size
--SNIP--
Specify the selected HMAC (MD5, say) in the configuratoin file as auth MD5.
Only one HMAC can be specified, and AFAIK there is no negotiation between the two peers.
- start both the peers (in any order) using the command:
[openvpn@mia openvpn]# openvpn --config openvpn.conf
Thu Jul 17 16:12:10 2003 0[0]: OpenVPN 1.4.1 i386-redhat-linux-gnu built on May 22 2003
Thu Jul 17 16:12:10 2003 1[0]: UDP link local (bound): [undef]:5000
Thu Jul 17 16:12:10 2003 2[0]: UDP link remote: 131.193.50.184:5000
Thu Jul 17 16:12:10 2003 3[0]: Static Encrypt: Cipher 'DES-CBC' initialized with 64 bit key
Thu Jul 17 16:12:10 2003 4[0]: Static Encrypt: Using 128 bit message digest 'MD5' for HMAC authentication
Thu Jul 17 16:12:10 2003 5[0]: Static Decrypt: Cipher 'DES-CBC' initialized with 64 bit key
Thu Jul 17 16:12:10 2003 6[0]: Static Decrypt: Using 128 bit message digest 'MD5' for HMAC authentication
Thu Jul 17 16:12:10 2003 7[0]: Data Channel MTU parms [ udp_mtu=1300 extra_frame=40 extra_buffer=0 extra_tun=0 dynamic = [ mtu_min_initial=MTU_INITIAL_UNDEF mtu_max_initial=MTU_INITIAL_UNDEF mtu_initial=MTU_SET_TO_MAX mtu_min=140 mtu_max=1300 mtu=1300 ]]
Thu Jul 17 16:12:10 2003 8[0]: TUN/TAP device tun0 opened
Thu Jul 17 16:12:10 2003 9[0]: /sbin/ifconfig tun0 192.168.254.200 pointopoint 192.168.254.201 mtu 1260
Thu Jul 17 16:12:10 2003 10[0]: /home/openvpn/bin/ip-up.sh tun0 1260 1300 192.168.254.200 192.168.254.201
[ip-up] -- tun0 1260 1300 192.168.254.200 192.168.254.201
Thu Jul 17 16:12:10 2003 11[0]: PTHREAD support initialized
Thu Jul 17 16:12:40 2003 12[0]: Peer Connection Initiated with 131.193.50.184:5000
Take a look at the messages to check the different parameters.