ep1
, ep2
and ep3
). In addition, a hypervisor with client services ( hpv1
) was present on the network. Ubuntu Server 16.04 installed on all machines. $ sudo apt-get update && sudo apt-get install tin
l2vpnnet
. Create a directory structure: $ sudo mkdir -p /etc/tinc/l2vpnnet/hosts
tinc.conf
file in the /etc/tinc/l2vpnnet
tinc.conf
and fill it with the following contents: # Name = ep1 # , — L2 Mode = switch # , Interface = tap0 # UDP Port = 655 # , ConnectTo = ep2 ConnectTo = ep3 ConnectTo = hpv1
/etc/tinc/l2vpnnet/ep1
and /etc/tinc/l2vpnnet/ep1
parameters into it: # Address = 100.101.102.103 655 # Cipher = aes-128-cbc Digest = sha1 # Compression = 0
$ cd /etc/tinc/l2vpnnet && sudo tincd -n l2vpnnet -K2048 Generating 2048 bits keys: ............................................+++ p .................................+++ q Done. Please enter a file to save private RSA key to [/etc/tinc/l2vpnnet/rsa_key.priv]: Please enter a file to save public RSA key to [/etc/tinc/l2vpnnet/hosts/ep1]:
/etc/tinc/l2vpnnet/hosts/ep1|ep2|ep3|hpv1
) should be placed with all members of the network in the /etc/tinc/l2vpnnet/hosts
./etc/tinc/nets.boot
file in order for tinc to start the VPN to our network automatically upon boot: $ sudo cat nets.boot #This file contains all names of the networks to be started #on system startup. l2vpnnet
tap0
device parameters to /etc/network/interfaces
: # auto tap0 # manual, IP bridge iface tap0 inet manual # tinc pre-up ip tuntap add dev $IFACE mode tap # ... post-down ip tuntap del dev $IFACE mode tap # , tinc tinc-net l2vpnnet
10.10.10.0/24
. We will configure the bridge interface and assign it an IP - for this we enter in /etc/network/interfaces
such information: auto br0 iface br0 inet static # , IP address 10.10.10.1 netmask 255.255.255.0 # , tinc vpn bridge_ports tap0 # spanning tree bridge- bridge_stp off # bridge_maxwait 5 # bridge_fd 0
$ sudo ifup tap0 && sudo ifup br0 $ ping -c3 10.10.10.2 PING 10.10.10.2 (10.10.10.2) 56(84) bytes of data. 64 bytes from 10.10.10.2: icmp_seq=1 ttl=64 time=3.99 ms 64 bytes from 10.10.10.2: icmp_seq=2 ttl=64 time=1.19 ms 64 bytes from 10.10.10.2: icmp_seq=3 ttl=64 time=1.07 ms --- 10.10.10.2 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2002ms rtt min/avg/max/mdev = 1.075/2.087/3.994/1.349 ms
$ sudo apt-get update && sudo apt-get install openvpn easy-rsa
vpn.compa.ny. IN A 100.101.102.103 vpn.compa.ny. IN A 50.51.52.53 vpn.compa.ny. IN A 1.1.1.1
Node 1 10.10.10.100-10.10.10.129 Node 2 10.10.10.130-10.10.10.159 Node 2 10.10.10.160-10.10.10.189
$ cd /etc/openvpn $ sudo -s # make-cadir ca # mkdir keys # chmod 700 keys # exit
vars
variables, setting the following values: # easy-rsa export EASY_RSA="`pwd`" # openssl, pkcs11-tool, grep export OPENSSL="openssl" export PKCS11TOOL="pkcs11-tool" export GREP="grep" # openssl export KEY_CONFIG=`$EASY_RSA/whichopensslcnf $EASY_RSA` # export KEY_DIR="$EASY_RSA/keys" export PKCS11_MODULE_PATH="dummy" export PKCS11_PIN="dummy" # export KEY_SIZE=2048 # CA- 10 export CA_EXPIRE=3650 # : , , # , , e-mail export KEY_COUNTRY="RU" export KEY_PROVINCE="Magadan region" export KEY_CITY="Susuman" export KEY_ORG="Company" export KEY_EMAIL="info@compa.ny" export KEY_OU="IT" export KEY_NAME="UnbreakableVPN"
# . vars # ./clean-all # ./build-ca Generating a 2048 bit RSA private key ..........................+++ .+++ writing new private key to 'ca.key' ----- 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) [RU]: State or Province Name (full name) [Magadan region]: Locality Name (eg, city) [Susuman]: Organization Name (eg, company) [Company]: Organizational Unit Name (eg, section) [IT]: Common Name (eg, your name or your server's hostname) [Company CA]: Name [UnbreakableVPN]: Email Address [info@compa.ny]: # ./build-dh Generating DH parameters, 2048 bit long safe prime, generator 2 This is going to take a long time … # ./build-key-server server # openvpn --genkey --secret keys/ta.key
# ./build-key testuser # ./revoke-full testuser
# cd keys # mkdir /etc/openvpn/.keys # cp ca.crt server.crt server.key dh2048.pem ta.key crl.pem /etc/openvpn/.keys # exit
/etc/openvpn/server.conf
file: # verb 4 # port 1194 proto tcp-server # mode server tls-server # MTU tun-mtu 1500 # , dev ovpn-clients dev-type tap # , TA- key-direction 0 # cert /etc/openvpn/.keys/server.crt key /etc/openvpn/.keys/server.key dh /etc/openvpn/.keys/dh2048.pem tls-auth /etc/openvpn/.keys/ta.key crl-verify /etc/openvpn/.keys/crl.pem # auth sha1 cipher AES-128-CBC # , , # persist-tun # topology subnet server-bridge 10.10.10.1 255.255.255.0 10.10.10.100 10.10.10.129 # # DNS push "redirect-gateway autolocal" push "dhcp-option DNS 10.10.10.200" push "dhcp-option DNS 10.20.20.200" # 10 , # — 2 keepalive 10 120 # 30 max-clients 30 # openvpn user nobody group nogroup # IP float # log /var/log/openvpn-server.log
/etc/network/interfaces
: auto ovpn-clients iface ovpn-clients inet manual pre-up ip tuntap add dev $IFACE mode tap post-up systemctl start openvpn@server.service pre-down systemctl stop openvpn@server.service post-down ip tuntap del dev $IFACE mode tap
br0
interface settings: ... netmask 255.255.255.0 bridge_ports tap0 bridge_ports ovpn_clients bridge_stp off ...
$ sudo ifup ovpn-clients && sudo ifdown br0 && sudo ifup br0
$ sudo -s # cd /etc/openvpn/ca # ./build-key PetrovIvan # exit
$ vim PetrovInan.ovpn # , client dev tap proto tcp # MTU , tun-mtu 1500 # remote vpn.compa.ny 1194 # nobind # , persist-key persist-tun # MSS mssfix # , TA TLS- key-direction 1 ns-cert-type server remote-cert-tls server auth sha1 cipher AES-128-CBC verb 4 keepalive 10 40 <ca> ### ca.crt </ca> <tls-auth> ### ta.key </tls-auth> <cert> ### PetrovIvan.crt </cert> <key> ### PetrovIvan.key </key>
$ ./revoke-all PetrovIvan
crl.pem
on all servers and execute: $ sudo service openvpn reload
server.conf
missing the persist-key
option. This allows you to update key information during the execution of a reload
- otherwise it would require a restart of the daemon.reload
action for OpenVPN, we use Chef. Obviously, any other means of automatic deployment of configurations (Ansible, Puppet ...) or even a simple shell script are suitable for this purpose.Source: https://habr.com/ru/post/338628/
All Articles