目的:為了實(shí)現(xiàn)外網(wǎng)訪問內(nèi)網(wǎng)服務(wù)器,實(shí)現(xiàn)內(nèi)網(wǎng)服務(wù)器的穿透
1.準(zhǔn)備工作
準(zhǔn)備一臺(tái)云服務(wù)器,這里使用阿里云服務(wù)器。下載frp,下載地址https://github.com/fatedier/frp/releases

image.png
2、搭建frp服務(wù)端,在我們的阿里云服務(wù)上,解壓

image.png
編輯frps.ini,其中auto_token要和客戶端配置的auto_token一致
[common]
bind_addr = 0.0.0.0
bind_port = 4443
auto_token = testtoken
啟動(dòng)服務(wù)端:
./frps -c ./frps.ini
3、安裝客戶端,我使用的是樹莓派位于內(nèi)網(wǎng),所以下載arm版本

image.png
解壓進(jìn)入安裝目錄
編輯frpc.ini,假設(shè)我們阿里云服務(wù)器ip是223.223.223.223
[common]
server_addr = 223.223.223.223
server_port = 4443
auto_token = testtoken
[test1]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 26666
[test2]
type = tcp
local_ip = 127.0.0.1
local_port = 8000
remote_port = 27777
啟動(dòng)客戶端
./frpc -c ./frpc.ini
4、這樣我們就把樹莓派22端口和8000端口代理出去了,可以通過(guò)223.223.223.223:26666 和223.223.223.223:27777 訪問.記得在阿里云安全組打開26666和27777端口,否則默認(rèn)是訪問不了的。