Openvpn – Why do I have 2 tun interfaces on the server

ifconfigopenvpntun

I have just configured watching this Hak5 video I found on Youtube.

But what is bothering me is that why do I have two tun interfaces on my server ?

Namely-:

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:10.8.0.1  P-t-P:10.8.0.2  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

tun1      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:10.8.0.1  P-t-P:10.8.0.2  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

As you can see they both have same inet addresses.

Also why I grep the openvpn process I get two pids returned to me, is that normal ?

root@ip-VPS:/etc/openvpn# pgrep openvpn
1681
1691

Any clue as to why this is happening ? What am I doing wrong ?

My server.conf is the following-:

port 53
proto udp
dev tun
ca ca.crt
cert server.crt
key server.key  # This file should be kept secret
dh dh2048.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
keepalive 10 120
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
verb 3

The output of ps -ef | grep openvpn is the following-:

root      1185     1  0 04:45 ?        00:00:00 /usr/sbin/openvpn --daemon ovpn-server.orig --status /run/openvpn/server.orig.status 10 --cd /etc/openvpn --script-security 2 --config /etc/openvpn/server.orig.conf --writepid /run/openvpn/server.orig.pid
nobody    1241     1  0 04:45 ?        00:00:00 /usr/sbin/openvpn --daemon ovpn-server --status /run/openvpn/server.status 10 --cd /etc/openvpn --script-security 2 --config /etc/openvpn/server.conf --writepid /run/openvpn/server.pid
root      1577  1517  0 04:48 pts/0    00:00:00 grep --color=auto openvpn

Best Answer

You have 2 copies of openvpn running because you have 2 valid config files

/etc/openvpn/server.orig.conf
/etc/openvpn/server.conf

You should have renamed the first such that it does not end with a .conf e.g. /etc/openvpn/server.conf.orig because by default openvpn creates an instance for each valid config file that it finds in the /etc/openvpn.