Random Forwarded Ports When Cascading VPNs

Erenys

Junior Member
When cascading VPns, the VPN Manager currently still doesn't display the 3 random opened ports. For sure there exists a formula to derive these 3 ports from the exit server's internal VPN IP, but manually using it each time is really boring and inconvenient

For Linux users, the FAQ offers a batch code to automate the calculation:
Code:
#!/bin/bash
[[ "$#" -eq 1 ]] || exit 1

IPv4_ADDR=${1}
IFS='.' read -ra ADDR <<< "$IPv4_ADDR"
function d2b() {
    printf "%08d" $(echo "obase=2;$1"|bc)
}
port_bin="$(d2b ${ADDR[2]})$(d2b ${ADDR[3]})"
port_dec=$(printf "%04d" $(echo "ibase=2;${port_bin:4}"|bc))
for i in 1 2 3; do
    echo "$i$port_dec"
done
But nothing for poor Windows users.

So, were it possible to translate the prev(c)ious code in a windows compliant one???

(The best would be that the Vpn Manager displays these ports, even when using a vpn cascade, though)
 
You can find it under the Server in main menu, click on details (the server that you connect with it) an you see your internal ip and the generatet ports ;)
 
Last edited by a moderator:
Or you can use this python3 script as exe in cmd:

or directly as script:

Python:
import re

# decimal number
ip = input("Enter your internel IP: ")

number = ip.split('.')
#print(number)
one = "0"+bin(int(number[2]))[2:]
two = bin(int(number[3]))[2:]

bina = one
bina += two

bintiny = bina[4:]
port = int(bintiny, 2)


for i in range(1, 4):
    print(str(i)+""+str(port))
 
You can find it under the Server in main menu, click on details (the server that you connect with it) an you see your internal ip and the generatet ports ;)

Thanks, but that trick works only when you are connected to 1 vpn server. In case of cascading, clicking on details just below the exit server doesn't display which ports are open on this exit server: In that case, only the internal IPs (internal server IP and internal vpn IP) are displayed. The VPN manager should calculate these ports itself, but it doesn't.

I will try the port.exe program and the script. Thank you.
 
Last edited:
I just tested port.exe.
A little inconvenience: It's not possible to enter the internal vpn IP in using the keyboard. I had to first write it in a text file, then copy it and paste it in the command window.

But the big problem is that the program seems to perform a false calculation: I tested in the case of a connection to 1 vpn server. In that case, the vpn manager calculates and displays the 3 opened ports. Running port.exe leads to completely different ports.
 
My bad bad: One really has to enter thne whole internal VPN IP.

But in that case, something gets really wrong as I'm back to the previous problem : With my internal VPN IP (10.1.1..147.xyz), port.exe give me the 3 ports 15108 25108 35108, which are absolutely not the 3 ports opened by the vpn.
 
I'm currently using the vpn on only one device. The test I performed above was with only 1 hop (to easily check whether the 3 ports calculated by port.exe were the good ones).
At this moment, with my internal Vpn IP 10.5.35.abc, the program gives the ports 1112, 2112, 3112. These ports are not at all those indicated by the vpn manager :(
 
hmm than they current bash code for linux no longer correct i think.... @PP Frank is the current bash script for linux users correct? is port forwarding allowed when we use hops?
 
Back
Top