:: Setting up VPN using LinVPN :: | |||
HOME |
------------------------------------- PPP-Client PPP-Server ------------------------------------- lock X X noauth X X debug X dump X logfd 2 X updetach X noccp X X ** novj X X ** novjccomp X X ** nopcomp X X ** noaccomp X X ****comment out the option if you want compression enabled in PPP.
~linvpn#>tar -xvzf LinVPN-version.tar.gz ~linvpn#>cd LinVPN-version ~linvpn#>mkdir /home/linvpn/etc; mkdir /home/linvpn/sbin ~linvpn#>./configure --prefix=/home/linvpn --config=/home/linvpn/etc ~linvpn#>make; make install
shashank@zidler:/home/linvpn/sbin# ls | more vpn-wrapper #wrapper program to execute certain commands like route, similar to sudo vpnd #Program to be run by the server vpncd #program to be run by the client vpndel #NOT REQUIRED. Same functionality availavle in vpncd and vpnd. vpnadd #Used to create a self-signed certificate. I Do not use this method.You can also get good explanation of setting up a linux-to-linux vpn by reading the How-To that comes with tarball, and this recipe will serve as a good supplement.
linvpn@zidler:/home/linvpn/sbin# ./vpnadd server testVPN 192.168.254.201:192.168.254.200 1024 Using configuration from /usr/share/ssl/openssl.cnf Generating a 1024 bit RSA private key ..++++++ ..........................................++++++ writing new private key to 'key.pem' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [US]: State or Province Name (full name) [Illinois]: Locality Name (eg, city) [Chicago]: Organization Name (eg, company) [UIC]: Organizational Unit Name (eg, section) [ECE]: Common Name (eg, your name or your server's hostname) []:linvpn Email Address []:[email protected] Adding VPN testVPN on server: done!At the end, you will get a cert.pem file, in /home/linvpn/sbin that you can send to the peer.
linvpn@zidler:/home/linvpn/sbin# cat key.pem -----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQCXX7qha8ZZRK1XzObWodf8m8SbmNLN0vKb6P7vPk81iTASV9Ok VlsBRVVEYsugRoM9iekCQGk9lqJ1DVvw3slJXrD//COqO/pmLDIoyf4cBDwg18FG wTnlVxGxO/iQ9vB/c/nNVJVIETqyQirg+ltx70XEfyo= --SNIP-- -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIIDJzCCAg+gAwIBAgIBDzANBgkqhkiG9w0BAQQFADCBqzE9MDsGA1UEAxM0Q2Vy dGlmaWNhdGUgQXV0aG9yaXR5IENyZWF0ZWQgYnkgU2hhc2hhbmsgS2hhbnZpbGth cjERMA8GA1UECBMISWxsaW5vaXMxCzAJBgNVBAYTAlVTMSMwIQYJKoZIhvcNAQkB FhRzaGFzaGFua0BldmwudWljLmVkdTElMCMGA1UEChMcUm9vdCBDZXJ0aWZpY2F0 Bcn3QAUVbzbTkRT06UH23Uc3Q/gQAfabSFPmKUznN7muoyBCfDPDEOXSWw== --SNIP-- -----END CERTIFICATE-----NOTE: The blank line between the certificate and the private key.
1. linvpn@zidler:/home/linvpn/sbin# ./vpnd daemon ------------------------------------------------------------------------------- 2. linvpn@zidler:/home/linvpn/sbin# ./vpnd --help usage: ./vpnd [command [option(s)]] Avaliable commands: insert vpn_name local:remote : Insert a new entry remove vpn_name : Remove an existing entry fetch vpn_name : Fetch an existing entry change vpn_name local:remote : Change an existing entry list : Show all entries stats : Show connected clients disconnect vpn_name : Disconnect a client event vpn_name [conn|disco] : Edit VPN events setkey vpn_name keyfile.pem : Set RSA private key dumpkey vpn_name : Dump key to stdout daemon : Run daemon --version : Show version --help : This help ------------------------------------------------------------------------------- 3. linvpn@zidler:/home/linvpn/sbin# ./vpnd insert testVPN 192.168.254.201:192.168.254.200 Entry testVPN has been added successfully! ------------------------------------------------------------------------------- 4. linvpn@zidler:/home/linvpn/sbin# ./vpnd setkey testVPN key.pem Keyfile of testVPN has been saved successfully! ------------------------------------------------------------------------------- 5. linvpn@zidler:/home/linvpn/sbin# ./vpnd dumpkey testVPN -----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQCXX7qha8ZZRK1XzObWodf8m8SbmNLN0vKb6P7vPk81iTASV9Ok gF4v9OZBADj2wKeuE7Ex5j8+LzfN2Lch/P2ntQMZy/te6i+0YPSVTLOF57nswdn1 --SNIP-- -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIIDJzCCAg+gAwIBAgIBDzANBgkqhkiG9w0BAQQFADCBqzE9MDsGA1UEAxM0Q2Vy dGlmaWNhdGUgQXV0aG9yaXR5IENyZWF0ZWQgYnkgU2hhc2hhbmsgS2hhbnZpbGth cjERMA8GA1UECBMISWxsaW5vaXMxCzAJBgNVBAYTAlVTMSMwIQYJKoZIhvcNAQkB --SNIP-- -----END CERTIFICATE----- ------------------------------------------------------------------------------- 6. linvpn@zidler:/home/linvpn/sbin# setenv EDITOR pico 7. linvpn@zidler:/home/linvpn/sbin# ./vpnd event testVPN conn 8. linvpn@zidler:/home/linvpn/sbin# ./vpnd event testVPN disco -------------------------------------------------------------------------------The last two commands (7, 8) will open up the editor and you can add appropriate routing commands to it. For example, I added the following commands (though this did not work for me):
+/sbin/route add -net 192.168.0.0 netmask 255.255.255.0 dev $i
1. linvpn@mia:/home/linvpn/sbin# ./vpncd --help usage: ./vpncd command [option(s)] Avaliable commands: insert vpn_name remote_host : Insert a new entry remove vpn_name : Remove an existing entry fetch vpn_name : Fetch an existing entry change vpn_name remote_host : Change an existing entry list : Show all entries connect vpn_name [retry=#] : Make your VPN connection event vpn_name [conn|disco] : Edit VPN events setcert vpn_name cert.pem : Set a Certificate --version : Show version --help : This help ------------------------------------------------------------------------------- 2. linvpn@mia:/home/linvpn/sbin#./vpncd insert testVPN 131.193.50.184 Entry testVPN has been added successfully! ------------------------------------------------------------------------------- 3. linvpn@mia:/home/linvpn/sbin#./vpncd setcert testVPN cert.pem Keyfile for testVPN has been saved successfully! ------------------------------------------------------------------------------- 4. linvpn@mia:/home/linvpn/sbin# setenv EDITOR pico 5. linvpn@mia:/home/linvpn/sbin# ./vpnd event testVPN conn 6. linvpn@mia:/home/linvpn/sbin# ./vpnd event testVPN disco ------------------------------------------------------------------------------- 7. linvpn@mia:/home/linvpn/sbin# ./vpncd connect testVPNThe two commands (5, 6) will open up the editor and you can add appropriate routing commands to it. For example, I added the following commands (though this did not work for me):
+/sbin/route add -net 192.168.2.0 netmask 255.255.255.0 dev $i
[shashank@mia sbin]# ifconfig ppp0 Link encap:Point-to-Point Protocol inet addr:192.168.254.200 P-t-P:192.168.254.201 Mask:255.255.255.255 UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1 RX packets:4 errors:0 dropped:0 overruns:0 frame:0 TX packets:4 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:3 RX bytes:56 (56.0 b) TX bytes:56 (56.0 b)
shashank@zidler:# route add -net 192.168.0.0 netmask 255.255.255.0 dev ppp0 --------------------------------------------------------------------------- shashank@mia:# route add -net 192.168.2.0 netmask 255.255.255.0 dev ppp0
+----------+----------+----------+ | Flag | Address | Control | | 01111110 | 11111111 | 00000011 | +----------+----------+----------+ +----------+-------------+---------+ | Protocol | Information | Padding | | 8/16 bits| * | * | +----------+-------------+---------+ +----------+----------+ | FCS | Flag | |16/32 bits| 01111110 | +----------+----------+PPP uses character/byte stuffing to escape the flags characters. However, in our experiments, we make sure that the input to PPP does not have any character that will be escaped.
2-byte Header 1-byte padding_length (ONLY IF PADDING IS PRESENT) m-byte MAC (message authentication code); e.g. SHA1 (20 Bytes), MD5 (16 Bytes) n1-byte payload; n2-byte random padding; (OPTIONAL. Will be added only if payload is not a multiple of BLOCK_SIZE for the cipher.)Note: The 1-byte padding_length field is optional, and may be present only if the packet is required to be padded, i.e. when the payload is not a multiple of the BLOCK_SIZE for the selected cipher. The presense/absense of the 1-byte padding_length field can be found out from the 1st MSB of the header.
fprintf (stdout, "SSL connection using %s\n", SSL_get_cipher (ssl));
> openssl ciphers -ssl2 -v DES-CBC3-MD5 SSLv2 Kx=RSA Au=RSA Enc=3DES(168) Mac=MD5 RC2-CBC-MD5 SSLv2 Kx=RSA Au=RSA Enc=RC2(128) Mac=MD5 RC4-MD5 SSLv2 Kx=RSA Au=RSA Enc=RC4(128) Mac=MD5 RC4-64-MD5 SSLv2 Kx=RSA Au=RSA Enc=RC4(64) Mac=MD5 DES-CBC-MD5 SSLv2 Kx=RSA Au=RSA Enc=DES(56) Mac=MD5 EXP-RC2-CBC-MD5 SSLv2 Kx=RSA(512) Au=RSA Enc=RC2(40) Mac=MD5 export EXP-RC4-MD5 SSLv2 Kx=RSA(512) Au=RSA Enc=RC4(40) Mac=MD5 export
seq_no: 0 Y%*i%|\NU]\Dw-5jOba4Q@D8`?5t#"iBFna^M1OF)t?6++f)m6ZIR:aOY3EvO1Tu!7UhI&0R6O%\uked#BIpvGARZfd+3; "Olq9Q3J@J5E(,2m,5KVA^}bLse2 4gcVI}C\ccB4*J[VTg(;YIyr.Gg/Z#C]Y)OBs{AXYU}&2Ut6w1+CG kn#zdA?D6H/ U&$lGwG9vgeg]7a+C@R]-\z)]=b=nGLEMQ31dtJ\^K_Wc\b(|Pe+I{N(;3EEtqjC^9nD/:)"|aeZ_)s2n ['i}\8D#.7)k2B\Vl2su4qThis data was generated using modudpgen, a synonym for Modified UDP generator and sniffed using ethereal.
noccp novj novjccomp nopcomp noaccompThe results are presented here.
seq_no: 0 Y%*i%|\NU]\Dw-5jOba4Q@D8`?5t#"iBFna^M1OF)t?6++f)m6ZIR:aOY3EvO1Tu!7UhI&0R6O%\uked#BIpvGARZfd+3; "Olq9Q3J@J5E(,2m,5KVA^}bLse2 4gcVI}C\ccB4*J[VTg(;YIyr.Gg/Z#C]Y)OBs{AXYU}&2Ut6w1+CG kn#zdA?D6H/ U&$lGwG9vgeg]7a+C@R]-\z)]=b=nGLEMQ31dtJ\^K_Wc\b(|Pe+I{N(;3EEtqjC^9nD/:)"|aeZ_)s2n ['i}\8D#.7)k2B\Vl2su4qThis data was generated using modudpgen, a synonym for Modified UDP generator and sniffed using ethereal.
route add -net network/netmask gw gateway-ip