0

There is a network I'm accessing using PPTP VPN. I'm trying to setup something to monitor if the network is accessible, and email me if not. I've got a Raspberry Pi, it's connected to the network itself via WLAN and to a mobile router via Ethernet.

Just making sure I understand netcat correctly, I'm checking if I can connect to google, the idea being, should this work, I'll just substitute host and port with vpn address and 1723 (for PPTP) and it will just work.

Using default interface (wlan0) works.

$ nc -vz www.google.com 80
Connection to www.google.com 80 port [tcp/http] succeeded!

But using the ethernet (eth0) it doesn't work.

$ nc -vz -s 192.168.1.102 www.google.com 80
nc: connect to www.google.com port 80 (tcp) failed: Connection timed out
nc: getaddrinfo: Address family for hostname not supported

Same if I substitute www.google.com with ip.

$ nc -vz -s 192.168.1.102 172.217.168.68 80
nc: connect to 172.217.168.68 port 80 (tcp) failed: Connection timed out

But curl works:

$ curl --interface eth0 --head www.google.com
HTTP/1.1 200 OK
[more stuff]

curl ifconfig.me and curl --interface eth0 ifconfig.me show different IP addresses, so I am confident both interfaces have access to the internet, are working, and are different.

The netcat is OpenBSD netcat.

$ nc -h
OpenBSD netcat (Debian patchlevel 1.195-2)

The machine is a default raspberry pi, the only configuration I did was setting the interfaces up.

What is it that may prevent netcat from working on one of the interfaces?

UPDATE

A workaround I found is nmap:

$ nmap --version
Nmap version 7.70 ( https://nmap.org )

$ nmap -e eth0 -p pptp -Pn my.vpn.host | grep "open"

0 Answers0