Intranet penetration-frp

The role of frp

1. Use a machine on the intranet or behind a firewall to provide http or https services to the external network environment.
2. For http and https services, it supports domain name-based virtual hosts and custom domain name binding, so that multiple domain names can share a port 80.
3. Use machines on the intranet or behind the firewall to provide TCP and UDP services to the external network environment, such as accessing hosts in the company's intranet environment through SSH at home.

Server configuration

Upload the Linux version of frp to the public server.

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-yj7pYSzM-1675817885357)(https://secure2.wostatic.cn/static/dvEw65vLqWUz69oAZeozmi/%E5%9B% BE%E7%89%87.png?auth_key=1673873591-cjLaf1MCWebyBzx6ULzL18-0-589cb0d2edab68d6eef6c4e5cd74c2dc#id=gKzIj&originHeight=357&originWidth=1653&rotinalType=binary&ratio=1& ation=0&showTitle=false&status=done&style=none&title=)]

unzip

[External link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-lPFUraWX-1675817885358)(https://secure2.wostatic.cn/static/75FT4bVwvfZ12DnTsMVS4L/%E5%9B% BE%E7%89%87.png?auth_key=1673873591-dAPi2d68At3fjRX9QwovJb-0-93a1180c34ce184daa90902d0f3afaa7#id=XhVii&originHeight=407&originWidth=1529&rotinalType=binary&ratio=1& ation=0&showTitle=false&status=done&style=none&title=)]

Enter the frp_0.39.1_linux_amd64 directory and modify the frps.ini file

cd frp_0.39.1_linux_amd64/
vi frps.ini

[common]
# frp监听的端口,默认是7000,可以改成其他的
bind_port = 7000
# 授权码,请改成更复杂的
token = 52010  # 这个token之后在客户端会用到

# frp管理后台端口,请按自己需求更改
dashboard_port = 7500
# frp管理后台用户名和密码,请改成自己的
dashboard_user = admin
dashboard_pwd = admin
enable_prometheus = true

# frp日志配置
log_file = /var/log/frps.log
log_level = info
log_max_days = 3

[External link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-0c9m8THR-1675817885359)(https://secure2.wostatic.cn/static/3ZXLzfNYAt2uWUymeSofBg/%E5%9B% BE%E7%89%87.png?auth_key=1673873591-epatEtQPVJmiV5VjgshxE8-0-56a74f1d49ae4ca0b45ade4771aedbeb#id=mwfFB&originHeight=436&originWidth=1246&originalType=binary&ratio=1&rotation=0& showTitle=false&status=done&style=none&title=)]

Set up and start frp service
sudo mkdir -p /etc/frp
sudo cp frps.ini /etc/frp
sudo cp frps /usr/bin
sudo cp systemd/frps.service /usr/lib/systemd/system/
sudo systemctl enable frps
sudo systemctl start frps

If the above commands are executed in sequence without any errors, the startup is successful.

Firewall open port

[External link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-aPLFetlW-1675817885360)(https://secure2.wostatic.cn/static/gWMTAKYCUdMrgjDeUwkrVS/%E5%9B% BE%E7%89%87.png?auth_key=1673873591-swHojSjVqRJJT1y7UNpMSg-0-945249fdfb75da9f064e9de93da7fbc2#id=eL3b6&originHeight=861&originWidth=1224&originalType=binary&ratio=1 &rotation=0&showTitle=false&status=done&style=none&title=)]

You can also execute the following command to open the port

# 添加监听端口
sudo firewall-cmd --permanent --add-port=7000/tcp
# 添加管理后台端口
sudo firewall-cmd --permanent --add-port=7500/tcp
sudo firewall-cmd --reload

Note: a. If it is ubuntu or centos 6, please use the ufw/iptables tool to release the port;
b. The two ports 7000 and 7500 correspond to bind_port and dashboard_port in the frps.ini configuration respectively.

Verify whether the server starts successfully

Visit: http://server IP :backend management port", enter the username and password to view the connection status, such as: http://yourip:7500, the username and password correspond to dashboard_user and dashboard_pwd in the frps.ini file respectively. After logging in, the interface is as follows :
[External link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-VEwP0T7Y-1675817885360)(https://secure2.wostatic.cn/static/rkVQQwtRHLvynKgodSXK5E/%E5%9B% BE%E7%89%87.png?auth_key=1673873591-tzPQ4BGSAyTJsD9ZHgUzdv-0-339c5af9f48e1dc7a5c85694dbd9bbbb#id=JVo5w&originHeight=932&originWidth=1776&originalType=binary&ratio=1& rotation=0&showTitle=false&status=done&style=none&title=)]

Client configuration

Unzip frp

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-h2bG5oP3-1675817885361)(https://secure2.wostatic.cn/static/92XgR8eHZu7kMN3uJLHhxT/%E5%9B% BE%E7%89%87.png?auth_key=1673873591-x6QsBUwHpZFtLGsVkxVikq-0-daa4ea1f8e588570faf861964817635b#id=IM4IN&originHeight=499&originWidth=1150&rotinalType=binary&ratio=1& ation=0&showTitle=false&status=done&style=none&title=)]

First delete the file starting with frps, and then configure it (frps is a server-side file)

Edit frpc.ini
[common]
server_addr = 124.220.180.128   #公网服务器ip
server_port = 7000            #与服务端bind_port一致

[yclj]
type = tcp
local_ip = 127.0.0.1
local_port = 22 # 22是Linux的远程连接端口
remote_port = 6000 # 远程服务器端口(自定义)

Guess you like

Origin blog.csdn.net/qq_53517370/article/details/128929215