1. Current Location: Home >  Router Encyclopedia >  Remote access direct connection and relay speed differ tenfold; the NAT hole punching principle is illustrated here

Remote access direct connection and relay speed differ tenfold; the NAT hole punching principle is illustrated here

NAT hole punching principle diagram: STUN asking for directions, exchanging notes, shooting and drilling the entire process; the symmetrical NAT failure is compared to the relay's bottom cover

Wrote < a href="https://www.shunot.com/en/nas/1190.html" > the Feiniu FN Connect articleAt that time, I left a tail note: transferring files from the company WiFi to my home NAS, 500KB/s, grinding a 2GB material package for over an hour; At night, my wife used her phone data to browse the NAS album at home, and the photos swiped at lightning speed, running right up to 50MB right next to our home. The same NAS, same account, can make a tenfold difference. Later, I checked the connection states on both sides and finally understood—her line was a direct device-to-device connection, while mine was a server-around relay. Deciding which path to take is one thing: whether the NAT is drilled or not. This isn't just FN Connect; Tencent Meeting, WeChat Video, Tailscale, and gaming multiplayer all share the same underlying system.

First, I spent a minute reviewing the NAT level

The devices at home all use internal network addresses like 192.168 or 31.x, which don't exist on the public network. When the packet goes out, the router changes the source address to the public IP of the WAN port, and casually records it on its mapping table: internal network 192.168.31.10:54321, external 117.136.x.x:56789 after leaving. The return packet is forwarded back to the corresponding device according to this table. I discussed this from the perspective of online gaming in my article NAT, and here I only emphasize one thing related to punching holes: the port that is dug out only gets a public IP and port number for outsiders. As for who can enter through this opening, the rules are set by each router.

Some routers are generous, with openings that let anyone through; Some are picky, but only those you've reached out to are acceptable; Others are the most cunning, changing their approach every time they contact a new target. This difference in temperament directly determines the success or failure of the drilling.

NAT has four temperaments; let's first look at the success or failure of the drill

Textbooks divide NAT into four types, with names like "cone" that sounds intimidating. Using a community parcel collection point as an analogy makes it clear:

rules : A hole is to . store only , the IP the rider you contacted you have contacted
Typecollection point example
fully tapereddrilled open, allowing any external addresscome in and paste your name on the shelf. Whoever places it will be forwarded
The restriction cone only allows the IP you have actively contacted. No matter whichaccepts your orders
port limit coneand port must matchonly the store
Every time you change destinations, you get a new entry. Each store will send you a new shelf number; old accounts become invalid

Most home routers use the first three types (collectively called conical). Once the port is drilled, the destination is the same mapping. The firewalls exported by companies and some carriers' CGNAT are symmetrical—this is a serious issue behind the scenes. As long as both sides of the NAT are conical, drilling holes is basically possible; As long as one side is symmetrical, there's basically no chance.

The entire process of making holes: asking for directions, exchanging points, and firing at each other

Both devices behind the NAT want to connect directly, and neither knows the other's public network address, so you have to follow the button in three steps.

Step one: Ask for directions. A and B each send a UDP package to a STUN server. What does STUN do? It's like a mirror—you send a contract to it, and it replies: "From the outside, I see you as 117.136.x.x:56789." This address is the address mapped by NAT. The standard port for STUN servers is 3478, and there are plenty of free ones on the public web—Google and Tencent have them.

Step two: Exchange. Both sides exchanged the house numbers they asked for through a third-party channel. This channel is the work done by the login servers of FN Connect, Tencent Meeting, and Tailscale—it only delivers notes, never touches the data. So when those apps are disconnected and you can't log into the server, you can't even connect, and there's nowhere to deliver the notes.

Step three: shoot back. A contracts to B's house number, and B simultaneously contracts to A's house number. The clever part is in timing: before B's packet reaches A's NAT, A happens to actively send a packet to B. The record on A's NAT mapping table is still hot, and when B's packet arrives, it hits the table entry and lets it pass. The reverse is also true. The two openings were chiseled open to each other, and the hole was opened. The whole process usually takes several hundred milliseconds to a few seconds. When you see the app spinning "Connected," it's usually the shooter.

Why did both

video conferencing and remote networking start with UDP? Because UDP has no connection status, the packet can leave at will, making it ideal for this kind of "simultaneous mutual shooting" work. The article on TCP and UDP mentioned that TCP requires a handshake first, and the timing of both sides is misaligned, making drilling a whole order of magnitude harder. Generally, it's just used as a backup.

Why is symmetrical NAT hopeless, and how is the relay a safety net

?

The fatal flaw of symmetrical NAT lies here: when A asks STUN for directions, it uses Kou 1, but when it turns to contact B, NAT switches it to Kou 2. B received a note with the address of Kou Zi 1, which was sent over. A's NAT checked the form—there was no record of it, so he threw it away. The door number on the note was expired, and no matter how he tried, he couldn't make it. As long as one side is symmetrical, the direct connection to this road is basically sealed.

At this point, it's the relay's turn to appear. In jargon, it's called a TURN: both sides hand over data to one server, and the server passes it to the other. Throughout the process, the speed limit you see is the "bandwidth allocated to you by the server" and "the distance between you and the server." FN Connect free relay test ranges from 500KB/s to 1MB/s, with further discounts during evening peak hours; I tested the Synology QuickConnect relay with the same temperament in the QuickConnect article, and it also capped at a few MB/s. Why is it generally slow? Server bandwidth is real money, free speed limits are the norm, Tailscale's DERP and game accelerator's "dedicated line" are essentially all about this.

How do you know if you're a direct connection or a relay

?

The worst part of this is that if the hole fails, it won't report an error, and the software will silently downgrade to the relay. You can't see anything on the interface. You might think it's your internet connection or your NAS isn't working, but actually, you're just taking the wrong path. So he had to be the referee himself.

The first judge is speed. Running uplink at home (mine has 50MB uplink and about 5MB/s file transfers) is direct connection; If the device is consistently stuck between 500KB/s and 1MB/s, stationary and not affected by time periods, it's probably a relay. Relay has a characteristic of slow relay—it's consistently slow, unlike bandwidth congestion where nighttime is worse than daytime.

The second judge was the software itself. In Tencent Meeting's settings, you can view network statistics. The sending and receiving speed doesn't increase, but the latency is okay—it's a relay phase. Tailscale is more practical. On the backend management page, every connection is labeled as Direct or Derp (the name of its main relay), making it clear at a glance. That's why I recommend it as a testing tool—after connecting, just look at the labels and you'll see the quality of your path. For FN Connect and other systems that don't reveal their status, they use speed to deduce backwards. That's how I judged the 1190 article.

By the way, the same person switching networks can get different results: my home WiFi is a direct connection, my company's WiFi is a relay, and my phone's data is also directly connected. So when investigating, don't just focus on the one side at home and look at both sides.

The reality at home: CGNAT, IPv6, and the order of speed boosts

When it comes to their own broadband, these two realities are the most critical. One is CGNAT: WAN ports with addresses starting with 100.64 mean the operator is cramming you and hundreds of households behind the same public IP address, creating a huge NAT layer. Many regions still have symmetrical attitudes, worsening the success rate of hole drilling. How to check I wrote about checking public IPs. Check the WAN port address and then compare your phone's data to the outbound IP to get the answer. Another bad news is that China Mobile and some newly installed telecom broadband providers come with this treatment by default. If you can get a public network V4 for calls, try to get it.

The other is IPv6, which is the cure for the entire punch-hole game. Once each device gets the world's only v6 address, there's no such thing as "hiding behind the intranet"—the door is open, just knock. Both ends have V6, and remote networking apps automatically switch to V6 direct connection. My wife's phone can fill up data thanks to this—V6 coverage for cellular networks has long been standard. What I need to do at home is to sort out the V6. The router switch and the optical modem are two separate levels. Xiaomi routers have a switch in 31.1, I've stepped into this pit before. There are other details on the optical modem side. Bridge and routing modes are not the same.

As for my company's relay route, how did I manage it in the end: the access side had no V6, the outlet was symmetrical, and the software layer couldn't be saved. So I simply set my home side to a public IP with a high-level port, and used a VPN to go home or go straight home port mapping. With access to one side of the public network, the other party doesn't need to dig a hole and goes straight to your door, skipping the whole luck-based process.

As usual, here's the order: from free to paid

The cost : . . For . .
of every step
1Check IPv6 at both ends, try mobile data first (if you have v6, it's likely to connect directly) 0 yuan
210,000 local network calls, you need a public IPfor 0 yuan, so it's up to luck
3. Public IP + port mapping or VPN for home costs 0 to tens of yuan
4 None of these works. Just endure the relay or pay for the monthly fee

Next time remote access gets stuck on a PowerPoint slide, don't rush to blame the NAS for not working—see which path you're taking before deciding which end to treat.

Read More


Copyright Notice Scan to read on mobile
All Rights Reserved: 《SHUNOT》 => 《Remote access direct connection and relay speed differ tenfold; the NAT hole punching principle is illustrated here》
Article URL: https://www.shunot.com/en/lybk/1207.html
Unless otherwise stated, all articles are original by 《SHUNOT》. Reposting is welcome! Please indicate the original URL when reposting, thank you.

Contact Us

Online Consultation: Click here to send me a message

WeChat ID: master_135

Scan to follow