X
X
X
X

Knowledge Base

HomepageKnowledge BaseLinux - MultiVPS IPv6+IPv4How do I calculate the port range f...

How do I calculate the port range for IPv4 NAT?

(Last Updated: 29-10-2024. Technical changes/adjustments have occurred.)

How do I calculate my ports?

IPv4 NAT external 10-port range is, funnily, calculated from the end of your... IPv6 address. 
Ports are always pre-opened at the given range for you.

IPv6 is a hexadecimal system, meaning that, past the usual allocation 0-9 on a given IP, you also have A-F.  Our IPv6s are usually given sequentially, but, due to the NAT implementation being made later, port allocation is organized slightly differently to the IPv6 allocation. We'll now explain.

An IPv6 address can range at its end, e.g. f800-f809, and then go f80a, f80b, etc. The "Decimal Range" shows the IP order you are located at from a normal standpoint, from 1 to 255, and it's used in combination with hexadecimal values. Check this explanatory table:

Port Range for TCP

An address ending on, for example, f80e::1, for example, is the 14th address on the decimal range;
Our ports allocation for TCP starts at 10000, meaning that each block has ports 10000-10009, 10010-10019, etc;
Therefore, you multiply and subtract to have your correct port allowance:

14 x 10 = 140
Port Start: 10000
Your Block of IPv4 Ports: 10000+140 = 10140-10149 , minus 10 ports10130-10139 is your port range.

Let's assume a harder example, one earlier on the table, for example an address ending on f8d1::1.

Per the previous table, this is the 209th address on the list (Decimal Range says "d0-df" does the range 208-223, therefore d1 is one address later than d0, making it the 209th address);
Remember the port allocation starts at 10000;
Therefore, you multiply to have your port allowance:

209 x 10 = 2090
Port Start: 10000
Your Block of IPv4 TCP Ports: 10000+2090 = 12090-12099, minus 10 ports = 12080-12089 is your TCP port range.

You always locate the address on the hexadecimal scale first, count to the equivalent on the decimal scale after, and after that, you multiply. To have your correct port allowance, you always subtract at the end.

This way, you'll always know in which order your IP address is, and therefore, which ports you have available.

The rule is the same regardless of the end having numbers only, numbers+letters or letters only.

Port Range for UDP

The same formula applies, with three central differences:
- the port allowance is 5 ports, and not 10;
- it always starts later than TCP ports. Currently, at port 13000 in all MultiVPS servers. 
- the port subtraction is of 5 ports, and not 10.

Using the same 1st example of the address that ends on f80e::1, which is the 14th address on the port range, you also multiply and subtract to have your correct range:

14 x 5 = 70
Port Start: 13000
Your Block of IPv4 UDP Ports: 13000 + 70 = 13070-13074, minus 5 ports = 13065-13069 is your UDP port range.

In the future, some servers may have a different port start for UDP (e.g. 20000 instead of 13000). If and when that happens, you can always check which server you're at, and go to this article in order to check where the port ranges for UDP start. At any moment, you can also send us a ticket.

Inbound and outbound ports usage on TCP and UDP, summarized

Inbound: freely available via IPv6, supported over IPv4 on the 10-port range for TCP, and the 5-port range for UDP.
Outbound: freely available via IPv6, supported over IPv4 on the 10-port range for TCP, and the 5-port range for UDP. 

ICMP is not supported on this mode, however the forwarding is in place. Ports are opened automatically and global server-level listeners are in-place automatically - simply go ahead and use the range. If you want to test if your range is working on TCP and UDP, click here.

SSH and all TCP/UDP services at those port ranges are fully working. If you used to access the C-Servers Remote service, you don't need to do it now, as our NAT IPv4 will directly forward you to an SSH session, as long as the selected sshd_config port and the port range are respected. Enjoy!

Can't find the information you are looking for?

Create a Support Ticket
Did you find it useful?
(456 times viewed / 1 people found it helpful)

Powered by WISECP
Top