# cd /usr/ports/security/openvpn # make configure-recursiv install clean
# make configure-recursiv install clean - /usr/ports/security/openvpn
# mkdir /usr/local/etc/openvpn/ # mkdir /usr/local/etc/openvpn/ccd
# cp -r /usr/local/share/easy-rsa /usr/local/etc/openvpn/
# cd /usr/local/etc/openvpn/easy-rsa/
# sh
# . ./vars # ./clean-all # ./build-ca
# ./build-key-server vpn0.example.com
# ./build-dh
# ./build-key client
# exit
# /usr/local/sbin/openvpn --genkey --secret /usr/local/etc/openvpn/easy-rsa/keys/ta.key
# cat /usr/local/etc/openvpn/server.conf local vpn0.example.com port 1194 proto udp dev tun ca /usr/local/etc/openvpn/easy-rsa/keys/ca.crt cert /usr/local/etc/openvpn/easy-rsa/keys/vpn0.example.com.crt key /usr/local/etc/openvpn/easy-rsa/keys/vpn0.example.com.key dh /usr/local/etc/openvpn/easy-rsa/keys/dh1024.pem tls-server tls-auth /usr/local/etc/openvpn/easy-rsa/keys/ta.key 0 server 172.17.0.0 255.255.255.0 ifconfig-pool-persist ipp.txt client-config-dir ccd push "route 10.10.210.72 255.255.255.248" push "route 172.27.102.0 255.255.255.0" push "route 172.27.103.0 255.255.255.0" push "route 172.27.105.0 255.255.255.0" push "dhcp-option DNS 192.168.100.1" keepalive 10 120 comp-lzo user nobody group nobody persist-key persist-tun status openvpn-status.log verb 3
# cat /usr/local/etc/openvpn/ccd/client ifconfig-push 172.17.0.2 172.17.0.1
openvpn_enable="YES" openvpn_if="tun" openvpn_configfile="/usr/local/etc/openvpn/server.conf" openvpn_dir="/usr/local/etc/openvpn"
# /usr/local/etc/rc.d/openvpn start Starting openvpn. add net 172.17.0.0: gateway 172.17.0.2
ipfw_nat_load="YES" libalias_load="YES"
${ipfw} nat 1 config if re0 reset same_ports ${ipfw} add nat 1 ip from 172.17.0.0/24 to any via $INT_if ${ipfw} add nat 1 ip from any to $EXT_ip ${ipfw} add allow all from any to any
$ cd /usr/local/etc/openvpn/easy-rsa/ $ sudo /bin/sh # . ./vars NOTE: If you run ./clean-all, I will be doing a rm -rf on /usr/local/etc/openvpn/easy-rsa/keys # ./build-key _ Generating a 1024 bit RSA private key ......++++++ ....++++++ writing new private key to '_.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 source) [US]:RU State or Province Name (full name) [CA]:ZC Locality Name (eg, city) [SanFrancisco]:Zabubensk Organization Name (eg, company) [Fort-Funston]:JSC Zabuba Organizational Unit Name (eg, section) [changeme]:ITD Common Name (eg, your name or your server's hostname) [_]: !----------------------------------------------------------------------! ! ! . ! !----------------------------------------------------------------------! Name [changeme]: Email Address [mail@host.domain]:_@zabubensk.example.com Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: Using configuration from /usr/local/etc/openvpn/easy-rsa/openssl-0.9.8.cnf Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows countryName :PRINTABLE:'RU' stateOrProvinceName :PRINTABLE:'ZC' localityName :PRINTABLE:'Zabubensk' organizationName :PRINTABLE:'JSC Zabuba' organizationalUnitName:PRINTABLE:'ITD' commonName :PRINTABLE:'_' name :PRINTABLE:' ' emailAddress :IA5STRING:'_@zabubensk.example.com' Certificate is to be certified until Nov 12 06:24:49 2023 GMT (3650 days) Sign the certificate? [y/n]:y 1 out of 1 certificate requests certified, commit? [y/n]y Write out database with 1 new entries Data Base Updated # # exit
$ sudo ee /usr/local/etc/openvpn/ccd/_ ifconfig-push 172.17.0.118 172.17.0.117
$ sudo ee /usr/local/etc/openvpn/ccd/_ ifconfig-push 172.17.0.118 172.17.0.117 push "route 10.12.1.0 255.255.255.0" push "route 10.12.2.0 255.255.255.0" push "route 192.168.10.0 255.255.255.0"
[ 1, 2] [ 5, 6] [ 9, 10] [ 13, 14] [ 17, 18] [ 21, 22] [ 25, 26] [ 29, 30] [ 33, 34] [ 37, 38] [ 41, 42] [ 45, 46] [ 49, 50] [ 53, 54] [ 57, 58] [ 61, 62] [ 65, 66] [ 69, 70] [ 73, 74] [ 77, 78] [ 81, 82] [ 85, 86] [ 89, 90] [ 93, 94] [ 97, 98] [101,102] [105,106] [109,110] [113,114] [117,118] [121,122] [125,126] [129,130] [133,134] [137,138] [141,142] [145,146] [149,150] [153,154] [157,158] [161,162] [165,166] [169,170] [173,174] [177,178] [181,182] [185,186] [189,190] [193,194] [197,198] [201,202] [205,206] [209,210] [213,214] [217,218] [221,222] [225,226] [229,230] [233,234] [237,238] [241,242] [245,246] [249,250] [253,254]
$ sudo /usr/local/etc/rc.d/openvpn restart Stopping openvpn. Waiting for PIDS: 62293. Starting openvpn. add net 172.17.0.0: gateway 172.17.0.2
config
folder with all the content received from your system administrator. This folder contains your client certificates and VPN server connection settings.Source: https://habr.com/ru/post/267841/
All Articles