Fading Coder

One Final Commit for the Last Sprint

Home > Tools > Content

Establishing a Free NAT Service for Exposing Local Services to the Internet

Tools 3

Establishing a Free NAT Service for Exposing Local Services to the Internet

NPC is a cross-platform, lightweight, and free tool for creating NAT tunnels, enabling access to internal network services from the public internet. Its client is only about 3.5 MB, requires no installation, and supports HTTP(S) domain proxying, TCP, and UDP port forwarding. Its compatible with Windows, Linux, macOS, and Android.

Primary Use Cases

  • Local-to-remote debugging for WeChat, mobile apps, and web development.
  • Providing internet-facing services from a local server or data center lacking a public IP address.
  • Rapid demonstration of prototypes or demos.
  • Remote administration of servers (Linux/Windows), personal computers, databases, and virtual machines.
  • Hosting multiplayer game servers.
  • Enhancing access speeds for Synology NAS devices.
  • Publishing locally hosted web services to the internet.

Supported Deployment Environments

  • Windows, Linux, and Docker are all supported.

Configuring a Tunnel VKey

The service backend is provided for free. Users only need to download and configure the client software. This section explains how to obtain the necessary credentials from the service management portal.

1. Access the Management Portal
  • Navigate to the management website.
  • Use the provided QR code to log in via the associated mini-program. If the scan fails, please try again.
2. View Existing Tunnels
  • After logging in, select "NAT Tunnel List" from the left-side menu to view all configured tunnels. The list displays details such as tunnel name, access method, VKey, local target, data usage, and online status.
3. Create or Edit a Tunnel
  • Follow the on-page instructions to add a new tunnel or modify an existing one.
  • For HTTP users requiring a custom subdomain, please contact the service administrator. Note that subdomains must comply with relevant domain registration policies.
4. Save Configuration
  • Upon submission, you will be returned to the tunnel list. The VKey displayed for your tunnel is a critical secret required for client configuration; keep it confidential.

Client Setup and Connection

Only the client software needs to be deployed. For assistance during setup, please refer to the designated support community.

1. Windows Client Setup
1.1 Download the NPC Client
  • Direct Download: https://www.xujian.tech/raw/npc.zip
  • Alternative Mirror: Available via shared cloud storage links.
1.2 Extract and Configure
  • Extract the downloaded archive. Note: Security software may flag the executable due to its network tunneling function. You can add an exception for it. The software is open-source and unmodified.
  • Edit the primary configuration file:
# Edit the file: conf/npc.conf
[common]
server_addr=nat.xujian.tech:8024
conn_type=tcp
vkey=${YOUR_VKEY}
auto_reconnection=true
max_conn=1000
flow_limit=1000
rate_limit=1000
crypt=true
compress=true
disconnect_timeout=60
  • Replace ${YOUR_VKEY} with the actual VKey obtained in the previous section.
1.3 Launch the Client
  • Execute the npc.exe file. A successful launch will be indicated in the console window.
  • Once running, your configured local service (e.g., a web server) becomes accessible via the tunnel. The setup process for other protocols like TCP (for Remote Desktop, databases, etc.) is analogous.
2. Docker Deployment

Run the following command, substituting ${YOUR_VKEY} with your actual key:

docker run -d --name npc --net=host ffdfgdfg/npc -server=nat.xujian.tech:8024 -vkey=${YOUR_VKEY}
3. Linux Client Setup
# Download the Linux client
wget https://www.xujian.tech/raw/linux_amd64_client.zip
# Extract the archive (install 'unzip' if necessary, e.g., `yum install unzip -y` for CentOS)
unzip linux_amd64_client.zip
# Navigate into the extracted directory
cd linux_amd64_client
# Grant execute permission to the binary
chmod u+x npc
# Edit the configuration file
vim conf/npc.conf
# Insert your VKey into the configuration file and save.

# To start the service in the foreground:
./npc
# To start the service as a background daemon:
nohup ./npc > npc.log 2>&1 &
# To monitor the daemon's log output:
tail -f npc.log
4. Accessing Your Service
  • Local Access: Connect to your service using its local IP and port (e.g., http://localhost:8080).
  • Remote Access via Tunnel: Use the public domain or IP address provided by the tunnel service to access your local resource from anywhere on the internet. The specific domain name is assigned during tunnel configuration.
Tags: NATTunneling

Related Articles

Efficient Usage of HTTP Client in IntelliJ IDEA

IntelliJ IDEA incorporates a versatile HTTP client tool, enabling developres to interact with RESTful services and APIs effectively with in the editor. This functionality streamlines workflows, replac...

Installing CocoaPods on macOS Catalina (10.15) Using a User-Managed Ruby

System Ruby on macOS 10.15 frequently fails to build native gems required by CocoaPods (for example, ffi), leading to errors like: ERROR: Failed to build gem native extension checking for ffi.h... no...

Resolve PhpStorm "Interpreter is not specified or invalid" on WAMP (Windows)

Symptom PhpStorm displays: "Interpreter is not specified or invalid. Press ‘Fix’ to edit your project configuration." This occurs when the IDE cannot locate a valid PHP CLI executable or when the debu...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.