Configuring FRP for Secure Internal Network Access
FRP (Fast Reverse Proxy) is a reverse proxy tool written in Go that enables acccess to internal network services from external networks. It supports TCP, UDP, HTTP, and HTTPS protocols, allowing services behind firewalls or NAT to be exposed securely.
Key Features of FRP
- Expose HTTP, HTTPS, or remote services from machines behind firewalls.
- Support for virtual hosting based on domain names, enabling multiple domains to share a single port.
- Provide TCP and UDP services for external access, such as SSH connections to internal hosts.
Installation FRP is cross-platform and available for Windows, Linux, macOS, and ARM. Download the appropriate package from the GitHub releases page.
For Linux:
wget https://github.com/fatedier/frp/releases/download/v0.36.2/frp_0.36.2_linux_amd64.tar.gz
tar xzvf frp_0.36.2_linux_amd64.tar.gz
Configuration
Server Configuration
Create a server configuration file frps.ini:
[common]
bind_port = 7000
token = secure_token
- Adjust
bind_portas needed and ensure firewall rules allow traffic on this port.
Start the FRP server:
chmod 700 frps frps.ini
./frps -c ./frps.ini
Client Configuration
Create a client configuration file frpc.ini:
[common]
server_addr = public_ip_address
server_port = 7000
token = secure_token
[remote_access]
type = tcp
local_ip = 192.168.1.100
local_port = 3389
remote_port = 7000
- Replace
public_ip_addresswith the server's public IP and adjustlocal_ipandlocal_portfor the internal service.
Run the client on Windows:
cd C:\frp_0.36.2_windows_amd64
frpc.exe -c frpc.ini
Automating Client Startup
Using a Batch Script
Create a file start_frpc.bat:
cd C:\frp_0.36.2_windows_amd64
frpc.exe -c frpc.ini
Run this script to start the client.
Using a VBS Script for Auto-Start
Create a file frpc.vbs:
Set ws = CreateObject("Wscript.Shell")
ws.run "cmd /c C:\frp_0.36.2_windows_amd64\start_frpc.bat", vbhide
Place frpc.vbs in the Windows startup folder (shell:startup) to run on boot.
Using NSSM for Service Management Install NSSM and create a service:
nssm install frpc
nssm start frpc
Commands for service control:
- Start:
nssm start frpc - Stop:
nssm stop frpc - Restart:
nssm restart frpc - Edit:
nssm edit frpc - Remove:
nssm remove frpc
Optional: Enabling Dashboard
Add to frps.ini:
[common]
dashboard_addr = public_ip_address
dashboard_port = 7500
dashboard_user = admin
dashboard_pwd = admin
enable_prometheus = true
Allow port 7500 in the firewall:
firewall-cmd --zone=public --add-port=7500/tcp --permanent
Access the dashboard at http://public_ip_address:7500 with credentials admin/admin.
Verifying Open Ports Check open ports on the server:
firewall-cmd --zone=public --list-ports