Reconnect script

NordVP has this script:

while sleep 50; do
t=$(ping -c $n | grep -o -E '[0-9]+ packets r' | grep -o -E '[0-9]+')
if [ "$t" -eq 0 ]; then
/etc/init.d/openvpn restart

But I want to make my own by just using syn-ack to the DNS server. However busybox's netcat lacks some options.

Is there a workaround or something else I can use instead?

So I can do something like this:

# pseudo code, do not use!
while sleep 299; do
  nc -z <dns_ip> <dns_port> || /etc/init.d/openvpn restart

Thanks much :smiley:


Why not use NordVPN over WireGuard? I use that 24/7 and it never disconnects.


1 Like

Well, basically because I'm completely illiterate when it comes to OpenVPN or WireGuard for that matter.

And I was just really happy that I got OpenVPN working at all :laughing:

opkg update; opkg install netcat
root@MikroTik:~# netcat -h
GNU netcat 0.7.1, a rewrite of the famous networking tool.
Basic usages:
connect to somewhere:  netcat [options] hostname port [port] ...
listen for inbound:    netcat -l -p port [options] [hostname] [port] ...
tunnel to somewhere:   netcat -L hostname:port -p port [options]

Mandatory arguments to long options are mandatory for short options too.
  -c, --close                close connection on EOF from stdin
  -e, --exec=PROGRAM         program to exec after connect
  -g, --gateway=LIST         source-routing hop point[s], up to 8
  -G, --pointer=NUM          source-routing pointer: 4, 8, 12, ...
  -h, --help                 display this help and exit
  -i, --interval=SECS        delay interval for lines sent, ports scanned
  -l, --listen               listen mode, for inbound connects
  -L, --tunnel=ADDRESS:PORT  forward local port to remote address
  -n, --dont-resolve         numeric-only IP addresses, no DNS
  -o, --output=FILE          output hexdump traffic to FILE (implies -x)
  -p, --local-port=NUM       local port number
  -r, --randomize            randomize local and remote ports
  -s, --source=ADDRESS       local source address (ip or hostname)
  -t, --tcp                  TCP mode (default)
  -T, --telnet               answer using TELNET negotiation
  -u, --udp                  UDP mode
  -v, --verbose              verbose (use twice to be more verbose)
  -V, --version              output version information and exit
  -x, --hexdump              hexdump incoming and outgoing traffic
  -w, --wait=SECS            timeout for connects and final net reads
  -z, --zero                 zero-I/O mode (used for scanning)
1 Like

Just out of curiosity:

Would it not be advisable to reconnect lets say, every 24 hrs for privacy reasons ? Can they learn anything based on the amount of traffic?

Ahhh, great :smiley:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.