How to check if the traffic is going through VPN and back?
How can I write an echo statement between a one OpenVPN client and another on the same virtual subnet provided by OpenVPN server in the middle? Like I want to echo a string from client and the other client should reply back with a string?
Use netcat
:
Host A: nc -nvlp 1234
Host B: nc [OpenVPN interface IP of Host A] 1234
(and hit Enter)
This will allow you to essentially "chat" back and forth between the 2 hosts over their respective OpenVPN interfaces.
Details:
Host A will be listening for traffic over port 1234 on all interfaces.
Host B will be communicating directly to the OpenVPN interface of Host A on port 1234.
If Host A is configured correctly, it will receive the traffic on the OpenVPN interface and echo it to STDOUT
.
If Host A is configured correctly, you will be able to echo a response back to Host B over the established socket between the OpenVPN interfaces of both hosts.
Like I said, this essentially creates a manual "chat" back and forth between the two hosts, so you will have to have a session open on each and manually enter messages to communicate from one host to the other.
MORE:
If you simply want one host to echo directly back what you have typed so that you know it has been received (without having to have constant manual interaction on the other host), you may want to use the nmap
version of netcat
called ncat
:
Host A: ncat -e /bin/cat -k -l 1234
Host B:
nc [OpenVPN interface IP of Host A] 1234
or
telnet [OpenVPN interface IP of Host A] 1234
Whatever you enter over the connection from Host B to Host A, should be echoed directly back from Host A to Host B directly over the established socket between the OpenVPN interfaces of both Host A and Host B.