My Centos version is 7.2.1511 ,Kernel 3.10.0-327.22.2.el7.x86_64 Accroding to the link
https://www.digitalocean.com/community/tutorials/how-to-setup-and-configure-an-openvpn-server-on-centos-7 ,I have installed Openvpn 2.1.3 on my CentOS 7,however it doesn't work.
the error was
[root@localhost centos7]# systemctl status -l
openvpn@server.service
openvpn@server.service - OpenVPN Robust And Highly Flexible Tunneling Application On server
Loaded: loaded (/usr/lib/systemd/system/openvpn@.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2016-07-23 09:37:42 EDT; 26s ago
Process: 2076 ExecStart=/usr/sbin/openvpn --daemon --writepid /var/run/openvpn/%i.pid --cd /etc/openvpn/ --config %i.conf (code=exited, status=1/FAILURE)
Jul 23 09:37:42 localhost.localdomain systemd[1]: Starting OpenVPN Robust And Highly Flexible Tunneling Application On server...
Jul 23 09:37:42 localhost.localdomain systemd[1]:
openvpn@server.service: control process exited, code=exited status=1
Jul 23 09:37:42 localhost.localdomain systemd[1]: Failed to start OpenVPN Robust And Highly Flexible Tunneling Application On server.
Jul 23 09:37:42 localhost.localdomain systemd[1]: Unit
openvpn@server.service entered failed state.
Jul 23 09:37:42 localhost.localdomain systemd[1]:
openvpn@server.service failed.
I don't like the default port which is 1194,I have change the port to 3000 and It's not be able to telnet the 3000 even I tried to start openvpn mannually,it seems doesn't work.
[root@localhost centos7]# openvpn /etc/openvpn/server.conf
[root@localhost centos7]# telnet localhost 3000
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
my server.conf was
[root@localhost openvpn]# cat openvpn.log
Sat Jul 23 10:48:08 2016 WARNING: Multiple --daemon directives specified, ignori ng --daemon openvpn. (Note that initscripts sometimes add their own --daemon dir ective.)
Sat Jul 23 10:48:08 2016 OpenVPN 2.3.11 x86_64-redhat-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [MH] [IPv6] built on May 10 2016
Sat Jul 23 10:48:08 2016 library versions: OpenSSL 1.0.1e-fips 11 Feb 2013, LZO 2.06
Sat Jul 23 10:48:08 2016 NOTE: your local LAN uses the extremely common subnet a ddress 192.168.0.x or 192.168.1.x. Be aware that this might create routing conf licts if you connect to the VPN server from public locations such as internet ca fes that use the same subnet.
Sat Jul 23 10:48:08 2016 Diffie-Hellman initialized with 1024 bit key
Sat Jul 23 10:48:08 2016 Control Channel Authentication: using '/etc/openvpn/ta. key' as a OpenVPN static key file
Sat Jul 23 10:48:08 2016 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Sat Jul 23 10:48:08 2016 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Sat Jul 23 10:48:08 2016 Socket Buffers: R=[212992->212992] S=[212992->212992]
Sat Jul 23 10:48:08 2016 ROUTE_GATEWAY 192.168.0.1/255.255.255.0 IFACE=enp3s0 HW ADDR=08:60:6e:d9:a1:6b
Sat Jul 23 10:48:08 2016 TUN/TAP device tun0 opened
Sat Jul 23 10:48:08 2016 TUN/TAP TX queue length set to 100
Sat Jul 23 10:48:08 2016 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Sat Jul 23 10:48:08 2016 /usr/sbin/ip link set dev tun0 up mtu 1500
Sat Jul 23 10:48:08 2016 /usr/sbin/ip addr add dev tun0 local 10.8.1.1 peer 10.8 .1.2
Sat Jul 23 10:48:08 2016 /usr/sbin/ip route add 10.8.1.0/24 via 10.8.1.2
Sat Jul 23 10:48:08 2016 GID set to nobody
Sat Jul 23 10:48:08 2016 UID set to nobody
Sat Jul 23 10:48:08 2016 UDPv4 link local (bound): [undef]
Sat Jul 23 10:48:08 2016 UDPv4 link remote: [undef]
Sat Jul 23 10:48:08 2016 MULTI: multi_init called, r=256 v=256
Sat Jul 23 10:48:08 2016 IFCONFIG POOL: base=10.8.1.4 size=62, ipv6=0
Sat Jul 23 10:48:08 2016 Initialization Sequence Completed
[root@localhost openvpn]# telnet localhost 3000
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
[root@localhost openvpn]#
[root@localhost openvpn]# telnet localhost 3000
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
[root@localhost openvpn]#
port 3000
#proto tcp
proto udp
dev tun
server 10.8.1.0 255.255.255.0
keepalive 20 120
ca /etc/keys/ca.crt
cert /etc/keys/server.crt
key /etc/keys/server.key
dh /etc/keys/dh1024.pem
#crl-verify keys/crl.pem
tls-auth /etc/keys/ta.key 0
cipher RC2-CBC
user nobody
group nobody
status openvpn-status.log
log-append openvpn.log
verb 2
mute 20
max-clients 200
#management 127.0.0.1 1199
#client-config-dir ccd
client-to-client
persist-key
persist-tun
#ccd-exclusive
#script-security 3 system
push "route 192.168.0.0 255.255.255.0"
push "redirect-gateway def1"
#push "dhcp-option DNS 8.8.8.8"
#push "dhcp-option DNS 8.8.6.6"
#status openvpn-status.log
comp-lzo
verb 3
daemon openvpn
My steps of Installation were
#1
yum install epel-release
#2
yum install openvpn easy-rsa -y
#3
cp /usr/share/doc/openvpn-*/sample/sample-config-files/server.conf /etc/openvpn
#4
vi /etc/openvpn/server.conf
#5
mkdir -p /etc/openvpn/easy-rsa/keys
#6
I copied the keys which was builded by my old server
#7
yum install iptables-services -y
#8
systemctl mask firewalld
#9
systemctl disable firewalld
#10
systemctl enable iptables
#11
systemctl stop firewalld
#12
systemctl start iptables
#13
iptables --flush
#14
yum remove firewalld
#15
iptables -t nat -A POSTROUTING -s 10.8.1.0/24 -o eth0 -j MASQUERADE
#16
iptables-save > /etc/sysconfig/iptables
#17
vi /etc/sysctl.conf
#18 Add the following line at the top of the file:
net.ipv4.ip_forward = 1
what wrong I have done?any idea?