OpenVPN in Debian 12, does not ping the server.

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
anndreih
Posts: 7
Joined: 2025-01-16 08:37
Has thanked: 3 times

OpenVPN in Debian 12, does not ping the server.

#1 Post by anndreih »

Hi all! I have been a linux user for some years although I'm very new to the networking aspects. This is the first time I will use OpenVPN and I have been strugling to make it work for a few days. I need to connect my home and work PCs (just two computers, each in a different location and with a different network) to use ssh in a way that I can access either computer. Then I could syncronize my files using the commands: sync, unison, etc.
Both computers are using Debian 12. In case this info could be relevant, one computer has the default Debian kernel: 6.1.0-30-amd64, arch: x86_64.
The other computer is using a newer kernel to achieve wifi compatibility: Kernel: 6.10.11+bpo-amd64 arch: x86_64. I would like to set both as server and client to access them from either location.

I installed the default OpenVPN in Debian 12:
OpenVPN 2.6.3 x86_64-pc-linux-gnu
library versions: OpenSSL 3.0.15 3 Sep 2024, LZO 2.10
Originally developed by James Yonan
Copyright (C) 2002-2023 OpenVPN Inc <sales@openvpn.net>

First I followed the wiki debian page: https://wiki.debian.org/OpenVPN:
In that page they first cover how to install and run openvpn in a raw unsecure connection just for testing. But the test didn't go well for me. Later they continue to configure openvpn which I also did, but still it seem not to work. Then I went through more complex guides on the net, configuring certificates, etc.... no luck. I think I should focus on that first step on the debian wiki page and find out why the raw test doesn't work.

So here are the steps I followed from the debian wiki:

Code: Select all

sudo apt-get install openvpn
sudo apt-get install network-manager-openvpn-gnome
On the server's firewall, open up UDP 1194 (default port).
I accomplished this using firewalld (which is the recommended program to reach the nftables in Debian).

Code: Select all

sudo apt install firewalld
sudo systemctl start firewalld
sudo systemctl enable firewalld
sudo firewall-cmd --add-port=1194/udp
I also check that the openvpn service was active and enable:

Code: Select all

sudo systemctl start openvpn.service

Code: Select all

sudo systemctl enable openvpn.service
And I included OpenVPN in the firewall too:

Code: Select all

sudo firewall-cmd --add-service openvpn.service
Here is the output of my firewalld configuration with the command: sudo firewall-cmd --list-all

Code: Select all

public (active)
target: default
icmp-block-inversion: no
interfaces: wlp7s0
sources:
services: dhcpv6-client openvpn ssh
ports: 1194/udp
protocols:
forward: yes
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
Since I want to use both computers as servers I did all those steps in both computers.

From one computer (let's call it the server now) I run an openvpn instance:

Code: Select all

sudo openvpn --remote CLIENT_IP --dev tun1 --ifconfig 10.9.8.1 10.9.8.2
If I understood it well, I have to replace CLIENT_IP with the public IP of the other computer (let's call it the client). I opted to get the IP using the command:

Code: Select all

curl https://api.ipify.org
and copy/paste the IP, replacing the CLIENT_IP part in the command above.

So here is the output of: sudo openvpn --remote xxx.xxx.xxx.xxx. --dev tun1 --ifconfig 10.9.8.1 10.9.8.2.

Code: Select all

2025-01-23 19:42:08 DEPRECATION: No tls-client or tls-server option in configuration detected. OpenVPN 2.7 will remove the functionality to run a VPN without TLS. See the examples section in the manual page for examples of a similar quick setup with peer-fingerprint.
2025-01-23 19:42:08 OpenVPN 2.6.3 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] [DCO]
2025-01-23 19:42:08 library versions: OpenSSL 3.0.15 3 Sep 2024, LZO 2.10
2025-01-23 19:42:08 DCO version: N/A
2025-01-23 19:42:08 ******* WARNING *******: '--cipher none' was specified. This means NO encryption will be performed and tunnelled data WILL be transmitted in clear text over the network! PLEASE DO RECONSIDER THIS SETTING!
2025-01-23 19:42:08 ******* WARNING *******: '--auth none' was specified. This means no authentication will be performed on received packets, meaning you CANNOT trust that the data received by the remote side have NOT been manipulated. PLEASE DO RECONSIDER THIS SETTING!
2025-01-23 19:42:08 ******* WARNING *******: All encryption and authentication features disabled -- All data will be tunnelled as clear text and will not be protected against man-in-the-middle changes. PLEASE DO RECONSIDER THIS CONFIGURATION!
2025-01-23 19:42:08 TUN/TAP device tun1 opened
2025-01-23 19:42:08 net_iface_mtu_set: mtu 1500 for tun1
2025-01-23 19:42:08 net_iface_up: set tun1 up
2025-01-23 19:42:08 net_addr_ptp_v4_add: 10.9.8.1 peer 10.9.8.2 dev tun1
2025-01-23 19:42:08 TCP/UDP: Preserving recently used remote address: [AF_INET]xxx.xxx.xxx.xxx:1194
2025-01-23 19:42:08 UDPv4 link local (bound): [AF_INET][undef]:1194
2025-01-23 19:42:08 UDPv4 link remote: [AF_INET]xxx.xxx.xxx.xxx:1194
So I got this good line saying: TUN/TAP device tun1 opened

While openvpn is running, I execute from another terminal the command "ip a" and get this output:

Code: Select all

tun1: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 500
    link/none
    inet 10.9.8.1 peer 10.9.8.2/32 scope global tun1
       valid_lft forever preferred_lft forever
I then continue with the debian wiki page, go to the client and run:

Code: Select all

sudo openvpn --remote SERVER_IP --dev tun1 --ifconfig 10.9.8.2 10.9.8.1
replacing now the SERVER_IP too with the public IP of the "server" computer.
I get a very similar output as before, just exchanging the 10.9.8.1 and 10.9.8.2.

I am also supposed to be able to ping the server: ping 10.9.8.1, but it doesn't work:
PING 10.9.8.1 (10.9.8.1) 56(84) bytes of data.
--- 10.9.8.1 ping statistics ---
11 packets transmitted, 0 received, 100% packet loss, time 10312ms

So please, could anyone help me about how and where could I start searching for the issue in my openvpn or my computers? What commands could I run for debugging? Could it be something with my router instead? In that case, how can I configure my router to let openvpn connections?

anndreih
Posts: 7
Joined: 2025-01-16 08:37
Has thanked: 3 times

Re: OpenVPN in Debian 12, does not ping the server.

#2 Post by anndreih »

Please, any extra info I could provide to help debug my issue? I still haven't solved it, still cannot ping the server. Update: I did port forwarding in my router, 1194/UDP to my PC (192.168.....), but it didn't help either.

Aki
Global Moderator
Global Moderator
Posts: 4259
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 124 times
Been thanked: 576 times

Re: OpenVPN in Debian 12, does not ping the server.

#3 Post by Aki »

Hello,
anndreih wrote: 2025-01-23 20:08 [..] I need to connect my home and work PCs (just two computers, each in a different location and with a different network) to use ssh in a way that I can access either computer. Then I could syncronize my files using the commands: sync, unison, etc.
Both computers are using Debian 12. [..]
Just a guess: both computers are behind a modem/router (with an active NAT, Network address translation) and cannot reach each other, aren't they ?

What are the IP address and default gateway of these two computers without trying to enable VPN?

You can check this on each computer using the following commands:

Code: Select all

ip address
ip route
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

anndreih
Posts: 7
Joined: 2025-01-16 08:37
Has thanked: 3 times

Re: OpenVPN in Debian 12, does not ping the server.

#4 Post by anndreih »

Thank you very much @Aki for your reply.

For now the PC at home is considered the server. This computer is behind a router. Without any instances of openVPN running I get that the IP of this PC is 192.168.14.7 (it connected to the router by an ethernet cable, LAN, no wifi). The default gateway of the router is 192.168.14.x (I access the web interface using 192.168.14.1).
Here is the command and output:

Code: Select all

>>> ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether b4:2c:99:91:2b:8f brd ff:ff:ff:ff:ff:ff
    inet 192.168.14.7/24 brd 192.168.14.255 scope global dynamic noprefixroute enp4s0
       valid_lft 2433sec preferred_lft 2433sec
    inet6 fe80::7bd2:ee41:ce2b:f48/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: wlo1: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 06:f2:6a:fb:ee:b1 brd ff:ff:ff:ff:ff:ff permaddr f8:1a:68:d1:47:fa
    altname wlp3s0

Code: Select all

>>> ip route
default via 192.168.14.1 dev enp4s0 proto dhcp src 192.168.14.7 metric 100 
192.168.14.0/24 dev enp4s0 proto kernel scope link src 192.168.14.7 metric 100
The other PC (client), located at workplace, is also behind a router, connected via wifi to the router. The IP in that computer is 192.168.1.27. The default gateway, 192.168.1.1.

Both are connected to the internet via optic fiber.

As to whether the routers are running an active NAT, I am not sure but probably yes, since I followed this post and got several 'hops', using the command: traceroute <mypublicip>.

Also, both routers, from the client and server) have the firewalls active, at medium level of security.

Both routers are provided by the ISPs (the brands are Huawei and Livebox).

Is there any command I could try to look for any possible connectivity issues?
Last edited by anndreih on 2025-01-26 15:08, edited 3 times in total.

anndreih
Posts: 7
Joined: 2025-01-16 08:37
Has thanked: 3 times

Re: OpenVPN in Debian 12, does not ping the server.

#5 Post by anndreih »

---Update
I'm trying to check if port 1194/UDP is reachable in the server.

First I check that my firewalld.service is active and running. Then I check the configuration with:

Code: Select all

>>> sudo firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: enp4s0
  sources: 
  services: dhcpv6-client ipp ipp-client mdns openvpn samba-client ssh
  ports: 1194/udp 1194/tcp
  protocols: 
  forward: no
  masquerade: yes
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 
So 1194 ports, both UDP and TCP are open.

I check again my network interfaces:

Code: Select all

>>> ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether b4:2c:99:91:2b:8f brd ff:ff:ff:ff:ff:ff
    inet 192.168.14.7/24 brd 192.168.14.255 scope global dynamic noprefixroute enp4s0
       valid_lft 1865sec preferred_lft 1865sec
    inet6 fe80::7bd2:ee41:ce2b:f48/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: wlo1: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 06:f2:6a:fb:ee:b1 brd ff:ff:ff:ff:ff:ff permaddr f8:1a:68:d1:47:fa
    altname wlp3s0
Then I check if the openvpn port (1194) is reachable with:

Code: Select all

>>> nc -zv 127.0.0.1 22, 80
localhost [127.0.0.1] 22 (ssh) open
localhost [127.0.0.1] 80 (http) open

>>> nc -zv 127.0.0.1 1194
localhost [127.0.0.1] 1194 (openvpn) : Connection refused

>>> nc -zv -u 127.0.0.1 1194
localhost [127.0.0.1] 1194 (openvpn) : Connection refused
I run the above commands from the server itself. It seems the ports can not be accessed from outside, right? I checked that the 1194 UDP and TCP are still being forwarded in the router. So I'm guessing at this point that the problem is a firewall issue in my computer? Or am I missing something about my router? I'd very much appreciate any suggestion to trace where the blocking is.
Last edited by anndreih on 2025-01-26 16:13, edited 2 times in total.

anndreih
Posts: 7
Joined: 2025-01-16 08:37
Has thanked: 3 times

Re: OpenVPN in Debian 12, does not ping the server.

#6 Post by anndreih »

---another update: more debugging.

Checking now the firewall at the server computer level. To check if there isn't any cross incompatibility of firewall rules or applications in case I have messed up the system installing in the past extra packages, I checked what firewall is active, following this post.
I run:

Code: Select all

>>> sudo iptables-save
# Generated by iptables-save v1.8.9 (nf_tables) on Sun Jan 26 17:28:08 2025
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -s 10.8.0.0/24 -o 192.168.14.7 -j MASQUERADE
COMMIT
# Completed on Sun Jan 26 17:28:08 2025
So iptables is almost empty. Maybe I'm responsible for the MASQUERADE line when I tried to configure the openVPN in previous days.

I also run:

Code: Select all

>>> sudo systemctl status iptables.service 
Unit iptables.service could not be found.

Code: Select all

>>> sudo systemctl status ufw.service 
Unit ufw.service could not be found.

Code: Select all

>>> sudo systemctl status nftables.service 
○ nftables.service - nftables
     Loaded: loaded (/lib/systemd/system/nftables.service; enabled; preset: enabled)
     Active: inactive (dead) since Sat 2025-01-25 16:21:43 CET; 1 day 1h ago
   Duration: 3min 31.225s
       Docs: man:nft(8)
             http://wiki.nftables.org
   Main PID: 327 (code=exited, status=0/SUCCESS)
        CPU: 38ms

Code: Select all

>>> sudo systemctl status firewalld.service 
● firewalld.service - firewalld - dynamic firewall daemon
     Loaded: loaded (/lib/systemd/system/firewalld.service; enabled; preset: enabled)
     Active: active (running) since Sun 2025-01-26 17:34:25 CET; 7s ago
       Docs: man:firewalld(1)
   Main PID: 117632 (firewalld)
      Tasks: 2 (limit: 55255)
     Memory: 24.7M
        CPU: 360ms
     CGroup: /system.slice/firewalld.service
             └─117632 /usr/bin/python3 /usr/sbin/firewalld --nofork --nopid
Again the firewalld rules:

Code: Select all

>>> sudo firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: enp4s0
  sources: 
  services: dhcpv6-client ipp ipp-client mdns openvpn samba-client ssh
  ports: 1194/udp 1194/tcp
  protocols: 
  forward: no
  masquerade: yes
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 
Now more specifid on nftables:

Code: Select all

>>> sudo nft list tables
table ip nat
table inet firewalld
And the nftables rules:

Code: Select all

>>> sudo nft list ruleset
# Warning: table ip nat is managed by iptables-nft, do not touch!
table ip nat {
	chain POSTROUTING {
		type nat hook postrouting priority srcnat; policy accept;
		oifname "192.168.14.7" ip saddr 10.x.x.x/24 counter packets 0 bytes 0 masquerade
	}
}
table inet firewalld {
	ct helper helper-netbios-ns-udp {
		type "netbios-ns" protocol udp
		l3proto ip
	}

	chain mangle_PREROUTING {
		type filter hook prerouting priority mangle + 10; policy accept;
		jump mangle_PREROUTING_ZONES
	}

	chain mangle_PREROUTING_POLICIES_pre {
		jump mangle_PRE_policy_allow-host-ipv6
	}

	chain mangle_PREROUTING_ZONES {
		iifname "enp4s0" goto mangle_PRE_public
		goto mangle_PRE_public
	}
[............]
	chain filter_IN_public_pre {
	}

	chain filter_IN_public_log {
	}

	chain filter_IN_public_deny {
	}

	chain filter_IN_public_allow {
		tcp dport 22 accept
		ip6 daddr fe80::/64 udp dport xxx accept
		udp dport 631 accept
		ip daddr 224.0.0.251 udp dport xxxx accept
		ip6 daddr ff02::fb udp dport xxxx accept
		tcp dport xxx accept
		udp dport xxx ct helper set "helper-netbios-ns-udp"
		udp dport xxx accept
		udp dport xxx accept
		udp dport 1194 accept
		tcp dport 1194 accept
	}

	chain filter_IN_public_post {
	}

	chain nat_POST_public {
		jump nat_POSTROUTING_POLICIES_pre
		jump nat_POST_public_pre
		jump nat_POST_public_log
		jump nat_POST_public_deny
		jump nat_POST_public_allow
		jump nat_POST_public_post
		jump nat_POSTROUTING_POLICIES_post
	}
[...............]
	chain filter_FWD_public {
		jump filter_FORWARD_POLICIES_pre
		jump filter_FWD_public_pre
		jump filter_FWD_public_log
		jump filter_FWD_public_deny
		jump filter_FWD_public_allow
		jump filter_FWD_public_post
		jump filter_FORWARD_POLICIES_post
		reject with icmpx admin-prohibited
	}

	chain filter_FWD_public_pre {
	}

	chain filter_FWD_public_log {
	}

	chain filter_FWD_public_deny {
	}

	chain filter_FWD_public_allow {
	}

	chain filter_FWD_public_post {
	}

	chain nat_PRE_public {
		jump nat_PREROUTING_POLICIES_pre
		jump nat_PRE_public_pre
		jump nat_PRE_public_log
		jump nat_PRE_public_deny
		jump nat_PRE_public_allow
		jump nat_PRE_public_post
		jump nat_PREROUTING_POLICIES_post
	}
[.................]
}
In the above lines, giving my inexperience in the networking aspects, I replaced some IPs with 'xxx'. Also, the final output was very long and was cut down in some parts.

I guess evrything points at nftables and firewalld as the backend and frontend firewall apps, which is the default and recommended setting for debian.

So to sum up, I have apparently everything set to allow traffic in the 1194 udp port, but it seems I can not reach it from outside. Please, could someone confirm this interpretation is correct? Any clue about how could I solve it?
Last edited by anndreih on 2025-01-26 16:53, edited 2 times in total.

anndreih
Posts: 7
Joined: 2025-01-16 08:37
Has thanked: 3 times

Re: OpenVPN in Debian 12, does not ping the server.

#7 Post by anndreih »

--- One more update.

When I open an instance of OpenVPN in the server by either of the following commands:

Code: Select all

>>> sudo openvpn  --dev tun1 --ifconfig 10.9.8.1 10.9.8.2
>>> sudo openvpn --remote <public_IP_of_client> --dev tun1 --ifconfig 10.9.8.1 10.9.8.2
I get that the port 1194 seems open:

Code: Select all

>>> nc -zv -u 127.0.0.1 1194
localhost [127.0.0.1] 1194 (openvpn) open
I still have to go to the other computer (client) and check if I can ping the server from there.

Aki
Global Moderator
Global Moderator
Posts: 4259
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 124 times
Been thanked: 576 times

Re: OpenVPN in Debian 12, does not ping the server.

#8 Post by Aki »

Hello,
Have you configured the modem/router to which the computer operating as openvpn server is connected to forward packets from a known external port to a port on the openvpn server?
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

anndreih
Posts: 7
Joined: 2025-01-16 08:37
Has thanked: 3 times

Re: OpenVPN in Debian 12, does not ping the server.

#9 Post by anndreih »

Hi @Aki, thank you very much for the follow-up.
Have you configured the modem/router to which the computer operating as openvpn server is connected to forward packets from a known external port to a port on the openvpn server?
I think I did. I'm attaching a screenshot of the forward rule I set in my router, please, could you check if I got it right. I only put the port number in the fields:
- Internal port number
- External port number

...choosing the same number for both fields.

Should I write something in the field "external source port number"? For now I simply left that blank.

Image
Last edited by anndreih on 2025-01-26 19:36, edited 1 time in total.

reinob
Section Moderator
Section Moderator
Posts: 1265
Joined: 2014-06-30 11:42
Has thanked: 131 times
Been thanked: 62 times

Re: OpenVPN in Debian 12, does not ping the server.

#10 Post by reinob »

I would try to remove/disable the firewall, because you seem to be making a mess with iptables, nftables, ufw and firewalld.

You should post your openvpn config (at least the one of the server). I bet the server is not listening on localhost (127.0.0.1), because why would a VPN server do that?

Normally the "local .." line should include the FQDN/IP which clients will use to access the server, so you'd need to check/post what you have on that line. If nothing is specified, then openvpn will bind to all interfaces, so presumably it would also listen on 127.0.0.1. But check that first.

reinob
Section Moderator
Section Moderator
Posts: 1265
Joined: 2014-06-30 11:42
Has thanked: 131 times
Been thanked: 62 times

Re: OpenVPN in Debian 12, does not ping the server.

#11 Post by reinob »

BTW Wireguard would be infinitely easier to set-up than OpenVPN.
Just sayin..

Aki
Global Moderator
Global Moderator
Posts: 4259
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 124 times
Been thanked: 576 times

Re: OpenVPN in Debian 12, does not ping the server.

#12 Post by Aki »

Hello,

That seems correct.

Note that all incoming openvpn traffic to 192.168.14.7:1194 (openvpn server) will have your modem/router IP address as the source IP address. So, you will need to configure the firewall on the openvpn server accordingly (or disable the firewall completely for troubleshooting purposes).

Note that the destination IP of the openvpn client must be configured with the IP address assigned to your modem/router by your ISP (or configure your modem/router to use a dynamic DNS service).

Hope this helps.
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

anndreih
Posts: 7
Joined: 2025-01-16 08:37
Has thanked: 3 times

Re: OpenVPN in Debian 12, does not ping the server.

#13 Post by anndreih »

Hello @reinob and @Aki, I liked and followed your suggestions about removing/disabling the firewall for troubleshooting....

So I stopped, disabled and uninstall firewalld. Just to check that it wasn't that I did something wrong within the firewalld app, after removing the firewalld from the system I installed the ufw firewall and opened the 1194 UDP port using ufw. But after running the openvpn instances I still couldn't ping the server from the client.

I stopped, disabled and removed ufw as well. So now I think I have not any frontend firewall apps running, just the backend nftables. I know this via the command: sudo systemctl --type=service and among many other services I can see this line:

Code: Select all

>>> sudo systemctl --type=service
  UNIT                          LOAD   ACTIVE SUB     DESCRIPTION
  nftables.service              loaded active exited  nftables
I also checked the service is enabled and running.

Code: Select all

>>> sudo systemctl status nftables.service 
● nftables.service - nftables
     Loaded: loaded (/lib/systemd/system/nftables.service; enabled; preset: ena>
     Active: active (exited) since Tue 2025-01-28 04:09:14 CET; 1h 44min ago
       Docs: man:nft(8)
             http://wiki.nftables.org
   Main PID: 318 (code=exited, status=0/SUCCESS)
        CPU: 16ms

I rebooted the system just in case, and the firewall frontends ufw or firewalld are still disabled and nftables loaded. I guess I don't need to turn off nftables since now the rule sets are kepted to a minimum, but please, tell me if I should do something to completely remove any firewall rules.

I'm providing here some info of how the server is at the moment. Note that Debian 12 comes with nftables by default, I've never used or tried to install iptables.

Code: Select all

>>> sudo nft list ruleset
table inet filter {
	chain input {
		type filter hook input priority filter; policy accept;
	}

	chain forward {
		type filter hook forward priority filter; policy accept;
	}

	chain output {
		type filter hook output priority filter; policy accept;
	}
}
Note that the above command, "sudo nft list ruleset", used to show a much longer list of rules (you can see that in one of my previous messages).

Code: Select all

>>> sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination   
(I read that although I can use iptables command, it is just kept as a wrapper for nftables).

One interesting thing noticed is that, apart from not being able to ping the server from the client when the openvpn tunnel is running (ping 10.9.8.1 from the client) I can not ping any other sites either and this is strange since I remember I had no problem pinging in the past.
So I can not ping "gugle", debian.forums, etc., or my own public ip. Here are the outputs of the ping command showing 100% packet lost:

Code: Select all

>>> ping -c 5 wiki.debian.org
PING wilder.debian.org (82.195.75.112) 56(84) bytes of data.
--- wilder.debian.org ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 4094ms

>>> ping -c 5 forums.debian.net
PING forums.debian.net (159.69.48.177) 56(84) bytes of data.
--- forums.debian.net ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 4073ms

>>> ping -c 5 xxx.xxx.xxx.xxx ##(public ip of server)
PING xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx) 56(84) bytes of data.
--- xxx.xxx.xxx.xxx ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 4073ms
The only thing that works is to ping localhost (127.0.0.1):

Code: Select all

>>> ping -c 5 localhost
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.038 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.029 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.037 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.033 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.059 ms
--- 127.0.0.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4097ms
rtt min/avg/max/mdev = 0.029/0.039/0.059/0.010 ms
Although I can not ping external sites, I can nmap:

Code: Select all

nmap -sT forums.debian.net
Starting Nmap 7.93 ( https://nmap.org ) at 2025-01-28 06:37 CET
Nmap scan report for forums.debian.net (159.69.48.177)
Host is up (0.081s latency).
Other addresses for forums.debian.net (not scanned): 2a01:4f8:1c17:7bb3::1
Not shown: 994 closed tcp ports (conn-refused)
PORT    STATE SERVICE
25/tcp  open  smtp
80/tcp  open  http
143/tcp open  imap
443/tcp open  https
587/tcp open  submission
993/tcp open  imaps
Nmap done: 1 IP address (1 host up) scanned in 2.71 seconds

I haven't opened ports through any firewall rules in the server yet. when I am not running any openvpn instances, port 1194 udp is closed:

Code: Select all

>>> nc -zv -u 127.0.0.1 1194
localhost [127.0.0.1] 1194 (openvpn) : Connection refused
But if I run an openvpn instance from the server, the ports appears open with that nc command:

Code: Select all

>>> nc -zv -u 127.0.0.1 1194
localhost [127.0.0.1] 1194 (openvpn) open
If I use the nmap command to check the 1194 port. When openvpn is not running that port doesn't show, only 123/udp and 5353/udp:

Code: Select all

>>> sudo nmap -sU localhost 
Starting Nmap 7.93 ( https://nmap.org ) at 2025-01-28 06:22 CET
Nmap scan report for localhost (127.0.0.1)
Host is up (0.0000060s latency).
Other addresses for localhost (not scanned): ::1
Not shown: 998 closed udp ports (port-unreach)
PORT     STATE         SERVICE
123/udp  open          ntp
5353/udp open|filtered zeroconf
Nmap done: 1 IP address (1 host up) scanned in 1.36 seconds
And when I run openvpn, the output of nmap is exactly the same as before, no 1194 port appears.

The "ss -tuln" command yields a similar output to the "nc" command commented above. Only shows the 1194 port when the openvpn is running. To sumup the output I only showed two lines, the remaining lines were replaced by [...].

Code: Select all

Netid  State   Recv-Q  Send-Q         Local Address:Port    Peer Address:Port Process  
[...]
udp    UNCONN  0       0                    0.0.0.0:1194         0.0.0.0:*          
[...]
tcp    LISTEN  0       80                 127.0.0.1:3316         0.0.0.0:*             
[...]
Finally I have just checked that if I connect my server PC to the internet using my mobile data (using the android option 'personal hotspot') I can ping any external sites normally. I got "5 packets transmitted, 5 received, 0% packet loss, time 4006ms".

So from this, should I suppose the problem is in my router? (I didn't change the last router configuration, still keeping the port forwarding setting as I commented earlier, showing a screenshot).

I've installed firewalld again to check if after the firewall 'cleaning' anything had changed:

Code: Select all

>>> sudo apt install firewalld
Checked that it is enabled and running:

Code: Select all

>>> sudo systemctl status firewalld.service 
● firewalld.service - firewalld - dynamic firewall daemon
     Loaded: loaded (/lib/systemd/system/firewalld.service; enabled; preset: enabled)
     Active: active (running) since Tue 2025-01-28 06:52:13 CET; 3min 7s ago
       Docs: man:firewalld(1)
   Main PID: 17447 (firewalld)
      Tasks: 2 (limit: 55255)
     Memory: 28.7M
        CPU: 643ms
     CGroup: /system.slice/firewalld.service
             └─17447 /usr/bin/python3 /usr/sbin/firewalld --nofork --nopid
I opened the 1194 port again (but it wasn't necessary since it seems it kepts the old rules somewhere). And now the nftables have the long list of rules.

I still can't ping external sites or the server (ping 10.9.8.1 from the client).

Please, I would appreciate further suggestions to try debug this connectivity issue.
Last edited by anndreih on 2025-01-28 06:11, edited 1 time in total.

anndreih
Posts: 7
Joined: 2025-01-16 08:37
Has thanked: 3 times

Re: OpenVPN in Debian 12, does not ping the server.

#14 Post by anndreih »

You should post your openvpn config (at least the one of the server). I bet the server is not listening on localhost (127.0.0.1), because why would a VPN server do that?
Thanks @reinob for this. Since I have removed openvpn and reinstalled it, my /etc/openvpn or /etc/openvpn/server folders don't contain any configuration files. When I test openvpn I'm just writing this command in the terminal (following the debian wiki):

Code: Select all

>>> sudo openvpn --remote <public_ip_client> --dev tun1 --ifconfig 10.9.8.1 10.9.8.2
And in the client:

Code: Select all

>>> sudo openvpn --remote <public_ip_server> --dev tun1 --ifconfig 10.9.8.2 10.9.8.1
If I understand well, if I use those commands, I don't use any configuration files, is this correct?

Before removing openvpn I made a security copy though, and here is the contents of /etc/openvpn/server.conf

Code: Select all

port 1194
proto udp
dev tun

ca /etc/openvpn/pki/ca.crt
cert /etc/openvpn/pki/issued/server.crt
key /etc/openvpn/pki/private/server.key # the server.key private key must be kept secret
dh /etc/openvpn/pki/dh.pem

# internal tun0 connection IP
server 10.50.8.0 255.255.255.0

ifconfig-pool-persist ipp.txt

keepalive 10 120

# Compression - must be turned on at both end
comp-lzo

persist-key
persist-tun

# parameters to be adjusted according to your network configuration
push "dhcp-option DNS 192.168.14.1"
push "dhcp-option DOMAIN std.local"
push "route 192.168.14.0 255.255.255.0"

status /var/log/openvpn-status.log

# verbose mode
verb 3
And there was another config file, this one quite long, in /etc/openvpn/server/server.conf

Code: Select all

#################################################
# Sample OpenVPN 2.0 config file for            #
# multi-client server.                          #
#                                               #
# This file is for the server side              #
# of a many-clients <-> one-server              #
# OpenVPN configuration.                        #
#                                               #
# OpenVPN also supports                         #
# single-machine <-> single-machine             #
# configurations (See the Examples page         #
# on the web site for more info).               #
#                                               #
# This config should work on Windows            #
# or Linux/BSD systems.  Remember on            #
# Windows to quote pathnames and use            #
# double backslashes, e.g.:                     #
# "C:\\Program Files\\OpenVPN\\config\\foo.key" #
#                                               #
# Comments are preceded with '#' or ';'         #
#################################################

# Which local IP address should OpenVPN
# listen on? (optional)
;local a.b.c.d

# Which TCP/UDP port should OpenVPN listen on?
# If you want to run multiple OpenVPN instances
# on the same machine, use a different port
# number for each one.  You will need to
# open up this port on your firewall.
port 1194

# TCP or UDP server?
;proto tcp
proto udp

# "dev tun" will create a routed IP tunnel,
# "dev tap" will create an ethernet tunnel.
# Use "dev tap0" if you are ethernet bridging
# and have precreated a tap0 virtual interface
# and bridged it with your ethernet interface.
# If you want to control access policies
# over the VPN, you must create firewall
# rules for the the TUN/TAP interface.
# On non-Windows systems, you can give
# an explicit unit number, such as tun0.
# On Windows, use "dev-node" for this.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
;dev tap
dev tun

# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel if you
# have more than one.  On XP SP2 or higher,
# you may need to selectively disable the
# Windows firewall for the TAP adapter.
# Non-Windows systems usually don't need this.
;dev-node MyTap

# SSL/TLS root certificate (ca), certificate
# (cert), and private key (key).  Each client
# and the server must have their own cert and
# key file.  The server and all clients will
# use the same ca file.
#
# See the "easy-rsa" directory for a series
# of scripts for generating RSA certificates
# and private keys.  Remember to use
# a unique Common Name for the server
# and each of the client certificates.
#
# Any X509 key management system can be used.
# OpenVPN can also use a PKCS #12 formatted key file
# (see "pkcs12" directive in man page).
ca /etc/openvpn/easy-rsa/pki/ca.crt
cert /etc/openvpn/easy-rsa/pki/issued/server.crt
key /etc/openvpn/easy-rsa/pki/private/server.key  # This file should be kept secret

# Diffie hellman parameters.
# Generate your own with:
#   openssl dhparam -out dh2048.pem 2048
dh /etc/openvpn/easy-rsa/pki/dh2048.pem

# Network topology
# Should be subnet (addressing via IP)
# unless Windows clients v2.0.9 and lower have to
# be supported (then net30, i.e. a /30 per client)
# Defaults to net30 (not recommended)
;topology subnet

# Configure server mode and supply a VPN subnet
# for OpenVPN to draw client addresses from.
# The server will take 10.8.0.1 for itself,
# the rest will be made available to clients.
# Each client will be able to reach the server
# on 10.8.0.1. Comment this line out if you are
# ethernet bridging. See the man page for more info.
server 10.8.0.0 255.255.255.0

# Maintain a record of client <-> virtual IP address
# associations in this file.  If OpenVPN goes down or
# is restarted, reconnecting clients can be assigned
# the same virtual IP address from the pool that was
# previously assigned.
ifconfig-pool-persist /var/log/openvpn/ipp.txt

# Configure server mode for ethernet bridging.
# You must first use your OS's bridging capability
# to bridge the TAP interface with the ethernet
# NIC interface.  Then you must manually set the
# IP/netmask on the bridge interface, here we
# assume 10.8.0.4/255.255.255.0.  Finally we
# must set aside an IP range in this subnet
# (start=10.8.0.50 end=10.8.0.100) to allocate
# to connecting clients.  Leave this line commented
# out unless you are ethernet bridging.
;server-bridge 10.8.0.4 255.255.255.0 10.8.0.50 10.8.0.100

# Configure server mode for ethernet bridging
# using a DHCP-proxy, where clients talk
# to the OpenVPN server-side DHCP server
# to receive their IP address allocation
# and DNS server addresses.  You must first use
# your OS's bridging capability to bridge the TAP
# interface with the ethernet NIC interface.
# Note: this mode only works on clients (such as
# Windows), where the client-side TAP adapter is
# bound to a DHCP client.
;server-bridge

# Push routes to the client to allow it
# to reach other private subnets behind
# the server.  Remember that these
# private subnets will also need
# to know to route the OpenVPN client
# address pool (10.8.0.0/255.255.255.0)
# back to the OpenVPN server.
;push "route 192.168.10.0 255.255.255.0"
;push "route 192.168.20.0 255.255.255.0"

# To assign specific IP addresses to specific
# clients or if a connecting client has a private
# subnet behind it that should also have VPN access,
# use the subdirectory "ccd" for client-specific
# configuration files (see man page for more info).

# EXAMPLE: Suppose the client
# having the certificate common name "Thelonious"
# also has a small subnet behind his connecting
# machine, such as 192.168.40.128/255.255.255.248.
# First, uncomment out these lines:
;client-config-dir ccd
;route 192.168.40.128 255.255.255.248
# Then create a file ccd/Thelonious with this line:
#   iroute 192.168.40.128 255.255.255.248
# This will allow Thelonious' private subnet to
# access the VPN.  This example will only work
# if you are routing, not bridging, i.e. you are
# using "dev tun" and "server" directives.

# EXAMPLE: Suppose you want to give
# Thelonious a fixed VPN IP address of 10.9.0.1.
# First uncomment out these lines:
;client-config-dir ccd
;route 10.9.0.0 255.255.255.252
# Then add this line to ccd/Thelonious:
#   ifconfig-push 10.9.0.1 10.9.0.2

# Suppose that you want to enable different
# firewall access policies for different groups
# of clients.  There are two methods:
# (1) Run multiple OpenVPN daemons, one for each
#     group, and firewall the TUN/TAP interface
#     for each group/daemon appropriately.
# (2) (Advanced) Create a script to dynamically
#     modify the firewall in response to access
#     from different clients.  See man
#     page for more info on learn-address script.
;learn-address ./script

# If enabled, this directive will configure
# all clients to redirect their default
# network gateway through the VPN, causing
# all IP traffic such as web browsing and
# and DNS lookups to go through the VPN
# (The OpenVPN server machine may need to NAT
# or bridge the TUN/TAP interface to the internet
# in order for this to work properly). 
;push "redirect-gateway def1 bypass-dhcp"

# Certain Windows-specific network settings
# can be pushed to clients, such as DNS
# or WINS server addresses.  CAVEAT:
# http://openvpn.net/faq.html#dhcpcaveats
# The addresses below refer to the public
# DNS servers provided by opendns.com.
;push "dhcp-option DNS 208.67.222.222"
;push "dhcp-option DNS 208.67.220.220"

# Uncomment this directive to allow different
# clients to be able to "see" each other.
# By default, clients will only see the server.
# To force clients to only see the server, you
# will also need to appropriately firewall the
# server's TUN/TAP interface.
;client-to-client

# Uncomment this directive if multiple clients
# might connect with the same certificate/key
# files or common names.  This is recommended
# only for testing purposes.  For production use,
# each client should have its own certificate/key
# pair.
#
# IF YOU HAVE NOT GENERATED INDIVIDUAL
# CERTIFICATE/KEY PAIRS FOR EACH CLIENT,
# EACH HAVING ITS OWN UNIQUE "COMMON NAME",
# UNCOMMENT THIS LINE OUT.
;duplicate-cn

# The keepalive directive causes ping-like
# messages to be sent back and forth over
# the link so that each side knows when
# the other side has gone down.
# Ping every 10 seconds, assume that remote
# peer is down if no ping received during
# a 120 second time period.
keepalive 10 120

# For extra security beyond that provided
# by SSL/TLS, create an "HMAC firewall"
# to help block DoS attacks and UDP port flooding.
#
# Generate with:
#   openvpn --genkey tls-auth ta.key
#
# The server and each client must have
# a copy of this key.
# The second parameter should be '0'
# on the server and '1' on the clients.
tls-auth ta.key 0 # This file is secret

# Select a cryptographic cipher.
# This config item must be copied to
# the client config file as well.
# Note that v2.4 client/server will automatically
# negotiate AES-256-GCM in TLS mode.
# See also the ncp-cipher option in the manpage
cipher AES-256-CBC

# Enable compression on the VPN link and push the
# option to the client (v2.4+ only, for earlier
# versions see below)
;compress lz4-v2
;push "compress lz4-v2"

# For compression compatible with older clients use comp-lzo
# If you enable it here, you must also
# enable it in the client config file.
;comp-lzo

# The maximum number of concurrently connected
# clients we want to allow.
;max-clients 100

# It's a good idea to reduce the OpenVPN
# daemon's privileges after initialization.
#
# You can uncomment this on non-Windows
# systems after creating a dedicated user.
;user openvpn
;group openvpn

# The persist options will try to avoid
# accessing certain resources on restart
# that may no longer be accessible because
# of the privilege downgrade.
persist-key
persist-tun

# Output a short status file showing
# current connections, truncated
# and rewritten every minute.
status /var/log/openvpn/openvpn-status.log

# By default, log messages will go to the syslog (or
# on Windows, if running as a service, they will go to
# the "\Program Files\OpenVPN\log" directory).
# Use log or log-append to override this default.
# "log" will truncate the log file on OpenVPN startup,
# while "log-append" will append to it.  Use one
# or the other (but not both).
;log         /var/log/openvpn/openvpn.log
;log-append  /var/log/openvpn/openvpn.log

# Set the appropriate level of log
# file verbosity.
#
# 0 is silent, except for fatal errors
# 4 is reasonable for general usage
# 5 and 6 can help to debug connection problems
# 9 is extremely verbose
verb 3

# Silence repeating messages.  At most 20
# sequential messages of the same message
# category will be output to the log.
;mute 20

# Notify the client that when the server restarts so it
# can automatically reconnect.
explicit-exit-notify 1
I'm afraid I don't see any line with the local word contain relevant information. Even so, If I use the commands I commented above, these configuration files are not used, right? Notice I think my issue, probably a connectivity blocking, seems to be beforehand, since I can not even test openvpn using the raw (unsecure) connection, or ping the server.

anndreih
Posts: 7
Joined: 2025-01-16 08:37
Has thanked: 3 times

Re: OpenVPN in Debian 12, does not ping the server.

#15 Post by anndreih »

Aki wrote: 2025-01-27 20:07 Note that all incoming openvpn traffic to 192.168.14.7:1194 (openvpn server) will have your modem/router IP address as the source IP address. So, you will need to configure the firewall on the openvpn server accordingly (or disable the firewall completely for troubleshooting purposes).

Note that the destination IP of the openvpn client must be configured with the IP address assigned to your modem/router by your ISP (or configure your modem/router to use a dynamic DNS service).
Thank you @Aki for this. I'm not used to many of the network words yet or to its complexity, so please, I hope you will bear with me. To be sure I understand your comment well,
will have your modem/router IP address as the source IP address. So, you will need to configure the firewall on the openvpn server accordingly
The only thing I thought the firewall needed is to open the 1194/UDP port. I already did that with

Code: Select all

>>> sudo firewall-cmd --add-port=1194/tcp
And I forwarded ports in my router to the local IP of the machine acting as server (192.168.14.7), as shown in a previous screenshot. But, maybe, should I also set that port forwarding as a rule in firewalld?

Regarding this:
Note that the destination IP of the openvpn client must be configured with the IP address assigned to your modem/router by your ISP (or configure your modem/router to use a dynamic DNS service).
Perhaps I already do this when I start openvpn instances from the command line like this?:

Code: Select all

sudo openvpn --remote <public_ip_client> --dev tun1 --ifconfig 10.9.8.1 10.9.8.2  #(written from the server)
sudo openvpn --remote <public_ip_server> --dev tun1 --ifconfig 10.9.8.2 10.9.8.1 #(written from the client)
To clarify this, yes, I use the public IPs that the ISP provides either in the server location and in the client location (I use two different public IPs).

reinob
Section Moderator
Section Moderator
Posts: 1265
Joined: 2014-06-30 11:42
Has thanked: 131 times
Been thanked: 62 times

Re: OpenVPN in Debian 12, does not ping the server.

#16 Post by reinob »

you did enable IP forwarding, right?

this may depend on how you set-up your networking, but you could check with

Code: Select all

cat /proc/sys/net/ipv4/ip_forward
Make sure it says "1".

anndreih
Posts: 7
Joined: 2025-01-16 08:37
Has thanked: 3 times

Re: OpenVPN in Debian 12, does not ping the server.

#17 Post by anndreih »

Thank you so much @reinob for the follow-up.

I have checked that the output of that command is "1":

Code: Select all

>>> cat /proc/sys/net/ipv4/ip_forward
1

reinob
Section Moderator
Section Moderator
Posts: 1265
Joined: 2014-06-30 11:42
Has thanked: 131 times
Been thanked: 62 times

Re: OpenVPN in Debian 12, does not ping the server.

#18 Post by reinob »

OK.

Just to double-check, I ran exactly the same two commands as you posted above, i.e.

Code: Select all

sudo openvpn --remote <public_ip_client> --dev tun1 --ifconfig 10.9.8.1 10.9.8.2  #(written from the server)
sudo openvpn --remote <public_ip_server> --dev tun1 --ifconfig 10.9.8.2 10.9.8.1 #(written from the client)
using two computers in my home network, and it worked directly with no problems (I could ping from both computers to both computers).

It may be that your problem is really with the router (at either the client or the server) and/or with your ISP.
I think this is hard to diagnose in a forum :).

Maybe you could try something "easier" like setting up a web server (tcp/80) in one of the computers and see if you can reach it from the other. Then do something similar with a simple udp server, e.g. using netcat,

at the server:

Code: Select all

netcat -u -l 1194
at the client

Code: Select all

netcat -u <server-ip> 1194
If this works, then you have "udp/1194" connectivity in one direction. Test in the other direction. If both OK, then openvpn *should* work fine. If something doesn't work, then the routers are doing something they shouldn't be doing..

Good luck!

Post Reply