使用frp進(jìn)行內(nèi)網(wǎng)穿透

frp 是一個(gè)專注于內(nèi)網(wǎng)穿透的高性能的反向代理應(yīng)用遭庶,支持 TCP承匣、UDP蓖乘、HTTP、HTTPS 等多種協(xié)議韧骗〖问悖可以將內(nèi)網(wǎng)服務(wù)以安全、便捷的方式通過(guò)具有公網(wǎng) IP 節(jié)點(diǎn)的中轉(zhuǎn)暴露到公網(wǎng)袍暴。

frp is a high-performance reverse proxy application focusing on intranet penetration, supporting multiple protocols such as TCP, UDP, HTTP, and HTTPS. Intranet services can be exposed to the public network through a relay with public network IP nodes in a safe and convenient way.

為什么使用 frp 些侍?

Why use frp?

通過(guò)在具有公網(wǎng) IP 的節(jié)點(diǎn)上部署 frp 服務(wù)端,可以輕松地將內(nèi)網(wǎng)服務(wù)穿透到公網(wǎng)政模,同時(shí)提供諸多專業(yè)的功能特性岗宣,這包括:

By deploying the frp server on a node with a public network IP, you can easily penetrate the internal network service to the public network, while providing many professional features, including:

客戶端服務(wù)端通信支持 TCP、KCP 以及 Websocket 等多種協(xié)議淋样。

The client-server communication supports multiple protocols such as TCP, KCP, and Websocket.

采用 TCP 連接流式復(fù)用耗式,在單個(gè)連接間承載更多請(qǐng)求,節(jié)省連接建立時(shí)間趁猴。

Use TCP connection streaming multiplexing to carry more requests between a single connection, saving connection establishment time.

代理組間的負(fù)載均衡刊咳。

Load balancing between proxy groups.

端口復(fù)用,多個(gè)服務(wù)通過(guò)同一個(gè)服務(wù)端端口暴露儡司。

Port reuse, multiple services are exposed through the same server port.

多個(gè)原生支持的客戶端插件(靜態(tài)文件查看娱挨,HTTP、SOCK5 代理等)便于獨(dú)立使用 frp 客戶端完成某些工作捕犬。

Multiple natively supported client plug-ins (static file viewing, HTTP, SOCK5 proxy, etc.) facilitate independent use of frp client to complete certain tasks.

高度擴(kuò)展性的服務(wù)端插件系統(tǒng)跷坝,方便結(jié)合自身需求進(jìn)行功能擴(kuò)展。

The highly extensible server-side plug-in system facilitates functional expansion according to your own needs.

服務(wù)端和客戶端 UI 頁(yè)面或听。

Server and client UI pages.

簡(jiǎn)單來(lái)說(shuō)探孝,frp是一個(gè)反向代理軟件,他的體積小巧功能強(qiáng)大誉裆,講內(nèi)網(wǎng)IP進(jìn)行frp反向代理后顿颅,即可使用代理IP進(jìn)行訪問(wèn)內(nèi)網(wǎng)機(jī)器的服務(wù),例如遠(yuǎn)程桌面足丢,雖然遠(yuǎn)程桌面有第三方軟件來(lái)代替粱腻,例如向日葵庇配,teamviewer,等一些軟件進(jìn)行遠(yuǎn)程绍些,這些軟件都有一些詬病捞慌,向日葵沒(méi)有會(huì)員會(huì)限速,而tv登錄遠(yuǎn)程連接會(huì)比較慢柬批。所以可以考慮到使用內(nèi)網(wǎng)穿透或者反向代理啸澡。

To put it simply, frp is a reverse proxy software, its size is small and powerful, after talking about the intranet IP for frp reverse proxy, you can use the proxy IP to access the services of the intranet machine, such as remote desktop, although remote desktop There are third-party software to replace, such as Sunflower, teamviewer, and other software for remote. These softwares have some criticisms. Sunflower does not have a membership rate limit, and the tv login remote connection will be slow. So you can consider using intranet penetration or reverse proxy.

內(nèi)網(wǎng)穿透可參考:有一個(gè)公網(wǎng)IP地址

Intranet penetration can refer to: there is a public IP address

使用端口進(jìn)行訪問(wèn)時(shí),原理如下

When using the port for access, the principle is as follows

準(zhǔn)備工作:

Ready to work:

1氮帐、首先得有一臺(tái)云服務(wù)器進(jìn)行提供網(wǎng)絡(luò)帶寬嗅虏,frp代理帶寬一般受限于該服務(wù)器帶寬

2、一臺(tái)目標(biāo)機(jī)器上沐,也就是需要反向代理的機(jī)器

1. First, there must be a cloud server to provide network bandwidth, and the frp proxy bandwidth is generally limited by the server bandwidth

2. A target machine, that is, a machine that needs a reverse proxy

云服務(wù)器端配置:

Cloud server configuration:

使用命令查看云服務(wù)器的架構(gòu)皮服,一般云服務(wù)器架構(gòu)為x86

Use commands to view the architecture of the cloud server, the general cloud server architecture is x86

[root@cby ~]# arch x86_64

使用命令下載frp軟件包

Use command to download frp package

[root@cby ~]# wget https://github.com/fatedier/frp/releases/download/v0.35.1/frp_0.35.1_linux_amd64.tar.gz

下載完成后進(jìn)行解壓

Unzip after downloading

[root@cby ~]# tar -xvf frp_0.35.1_linux_amd64.tar.gz

frp_0.35.1_linux_amd64/

frp_0.35.1_linux_amd64/frps.ini

frp_0.35.1_linux_amd64/frps_full.ini

frp_0.35.1_linux_amd64/systemd/

frp_0.35.1_linux_amd64/systemd/frpc@.service

frp_0.35.1_linux_amd64/systemd/frpc.service

frp_0.35.1_linux_amd64/systemd/frps.service

frp_0.35.1_linux_amd64/systemd/frps@.service

frp_0.35.1_linux_amd64/frpc

frp_0.35.1_linux_amd64/frpc_full.ini

frp_0.35.1_linux_amd64/frps

frp_0.35.1_linux_amd64/frpc.ini

frp_0.35.1_linux_amd64/LICENSE

修改文件夾名稱

Modify folder name

[root@cby ~]# cp -r frp_0.35.1_linux_amd64 frp

[root@cby ~]#

[root@cby ~]# ll

total 8508

drwxr-xr-x 3 root? root? ? 4096 Feb 19 22:13 frp

drwxr-xr-x 3 mysql? 116? ? 4096 Jan 25 16:25 frp_0.35.1_linux_amd64

-rw-r--r-- 1 root? root 8695632 Jan 25 16:25 frp_0.35.1_linux_amd64.tar.gz

只需要關(guān)注如下幾個(gè)文件

Only need to pay attention to the following files

frps

frps.ini

frpc

frpc.ini

frps 、frps.ini 這倆個(gè)文件是服務(wù)端的配置文件和啟動(dòng)程序

frpc参咙、frpc.ini 這倆個(gè)文件是客戶端的配置文件和啟動(dòng)程序

The two files frps and frps.ini are the configuration files and startup programs of the server

The two files frpc and frpc.ini are the configuration files and startup programs of the client

編輯并添加以下內(nèi)容

Edit and add the following

[root@cby frp]# vim frps.ini

[root@cby frp]# cat frps.ini

[common]

bind_port = 7000

dashboard_port = 7500

token = 12345678

dashboard_user = admin

dashboard_pwd = admin

vhost_http_port = 10080

vhost_https_port = 10443

解釋如下

Explain as follows

“bind_port”表示用于客戶端和服務(wù)端連接的端口龄广,這個(gè)端口號(hào)我們之后在配置客戶端的時(shí)候要用到。

“dashboard_port”是服務(wù)端儀表板的端口蕴侧,若使用7500端口择同,在配置完成服務(wù)啟動(dòng)后可以通過(guò)瀏覽器訪問(wèn) x.x.x.x:7500 (其中x.x.x.x為VPS的IP)查看frp服務(wù)運(yùn)行信息。

“token”是用于客戶端和服務(wù)端連接的口令戈盈,請(qǐng)自行設(shè)置并記錄奠衔,稍后會(huì)用到。

“dashboard_user”和“dashboard_pwd”表示打開儀表板頁(yè)面登錄的用戶名和密碼塘娶,自行設(shè)置即可。

“vhost_http_port”和“vhost_https_port”用于反向代理HTTP主機(jī)時(shí)使用痊夭,本文不涉及HTTP協(xié)議刁岸,因而照抄或者刪除這兩條均可。

文件修改完成后即可使用該命令進(jìn)行啟動(dòng)

After the file is modified, you can use this command to start

[root@cby frp]# ./frps -c frps.ini

2021/02/19 22:18:45 [I] [root.go:108] frps uses config file: frps.ini

2021/02/19 22:18:45 [I] [service.go:190] frps tcp listen on 0.0.0.0:7000

2021/02/19 22:18:45 [I] [service.go:232] http service listen on 0.0.0.0:10080

2021/02/19 22:18:45 [I] [service.go:253] https service listen on 0.0.0.0:10443

2021/02/19 22:18:45 [I] [service.go:289] Dashboard listen on 0.0.0.0:7500

2021/02/19 22:18:45 [I] [root.go:217] frps started successfully

若使用云服務(wù)器記得需要放行所需端口

If you use cloud server, remember to release the required port

此時(shí)訪問(wèn) x.x.x.x:7500 并使用自己設(shè)置的用戶名密碼登錄她我,即可看到儀表板界面

At this time, visit x.x.x.x:7500 and log in with the username and password you set, you can see the dashboard interface

把服務(wù)在后臺(tái)運(yùn)行即可

Just run the service in the background

[root@cby frp]# nohup ./frps -c frps.ini &

[1] 4852

[root@cby frp]# jobs

[1]+? Running? ? ? ? ? ? ? ? nohup ./frps -c frps.ini &

客戶端配置

Client configuration

Windows系統(tǒng)下即可下載這個(gè):

You can download this under Windows system:

https://github.com/fatedier/frp/releases/download/v0.35.1/frp_0.35.1_windows_amd64.zip

frpc.ini文件內(nèi)容為

The content of the frpc.ini file is

[common]

server_addr = 123.56.237.11

server_port = 7000

token = 12345678

[rdp]

type = tcp

local_ip = 127.0.0.1? ?

local_port = 3389

remote_port = 7001?

[smb]

type = tcp

local_ip = 127.0.0.1

local_port = 445

remote_port = 7002

含義解釋

Meaning interpretation

“server_addr”為服務(wù)端IP地址虹曙,填入即可。 “server_port”為服務(wù)器端口番舆,填入你設(shè)置的端口號(hào)即可酝碳,如果未改變就是7000 “token”是你在服務(wù)器上設(shè)置的連接口令,原樣填入即可恨狈。

自定義規(guī)則如下

The custom rules are as follows

“[xxx]”表示一個(gè)規(guī)則名稱疏哗,自己定義,便于查詢即可禾怠。 “type”表示轉(zhuǎn)發(fā)的協(xié)議類型返奉,有TCP和UDP等選項(xiàng)可以選擇贝搁,如有需要請(qǐng)自行查詢frp手冊(cè)。 “l(fā)ocal_port”是本地應(yīng)用的端口號(hào)芽偏,按照實(shí)際應(yīng)用工作在本機(jī)的端口號(hào)填寫即可雷逆。 “remote_port”是該條規(guī)則在服務(wù)端開放的端口號(hào),自己填寫并記錄即可污尉。

客戶端的啟動(dòng)是需要使用命令行進(jìn)行啟動(dòng)的膀哲, 無(wú)法使用雙擊EXE進(jìn)行啟動(dòng)。

The startup of the client needs to use the command line to start, it cannot be started by double-clicking the EXE.

C:\Users\Administrator>cd c:\

c:\>cd frp

c:\frp>frpc.exe -c frpc.ini

2021/02/19 22:35:49 [I] [service.go:290] [bf2998700defd7c5] login to server success, get run id [bf2998700defd7c5], server udp port [0]

2021/02/19 22:35:49 [I] [proxy_manager.go:144] [bf2998700defd7c5] proxy added: [rdp smb]

2021/02/19 22:35:49 [I] [control.go:180] [bf2998700defd7c5] [rdp] start proxy success

2021/02/19 22:35:49 [I] [control.go:180] [bf2998700defd7c5] [smb] start proxy success

配置完成后即可在面板上看到該規(guī)則

After the configuration is complete, you can see the rule on the panel

同時(shí)使用遠(yuǎn)程連接工具使用IP或者域名即可進(jìn)行連接

但是Windows客戶端的cmd是無(wú)法關(guān)閉的被碗,關(guān)閉后就無(wú)法使用了等太,所以需要設(shè)置開機(jī)自啟,使用bat腳本即可做到

At the same time, use the remote connection tool to connect using IP or domain name

However, the cmd of the Windows client cannot be closed, and it cannot be used after it is closed, so you need to set the boot to start automatically, and you can use the bat script

@echo off

if "%1" == "h" goto begin

mshta vbscript:createobject("wscript.shell").run("""%~nx0"" h",0)(window.close)&&exit

:begin

REM

cd C:\frp

frpc.exe -c frpc.ini

exit

寫完之后直接把文件扔到Windows的開機(jī)啟動(dòng)文件夾即可

After writing, throw the file directly into the Windows startup folder.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末蛮放,一起剝皮案震驚了整個(gè)濱河市缩抡,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌包颁,老刑警劉巖瞻想,帶你破解...
    沈念sama閱讀 206,126評(píng)論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異娩嚼,居然都是意外死亡蘑险,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,254評(píng)論 2 382
  • 文/潘曉璐 我一進(jìn)店門岳悟,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)佃迄,“玉大人,你說(shuō)我怎么就攤上這事贵少『乔危” “怎么了?”我有些...
    開封第一講書人閱讀 152,445評(píng)論 0 341
  • 文/不壞的土叔 我叫張陵滔灶,是天一觀的道長(zhǎng)普碎。 經(jīng)常有香客問(wèn)我,道長(zhǎng)录平,這世上最難降的妖魔是什么麻车? 我笑而不...
    開封第一講書人閱讀 55,185評(píng)論 1 278
  • 正文 為了忘掉前任,我火速辦了婚禮斗这,結(jié)果婚禮上动猬,老公的妹妹穿的比我還像新娘。我一直安慰自己表箭,他們只是感情好赁咙,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,178評(píng)論 5 371
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般序目。 火紅的嫁衣襯著肌膚如雪臂痕。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 48,970評(píng)論 1 284
  • 那天猿涨,我揣著相機(jī)與錄音握童,去河邊找鬼。 笑死叛赚,一個(gè)胖子當(dāng)著我的面吹牛澡绩,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播俺附,決...
    沈念sama閱讀 38,276評(píng)論 3 399
  • 文/蒼蘭香墨 我猛地睜開眼肥卡,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了事镣?” 一聲冷哼從身側(cè)響起步鉴,我...
    開封第一講書人閱讀 36,927評(píng)論 0 259
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎璃哟,沒(méi)想到半個(gè)月后氛琢,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 43,400評(píng)論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡随闪,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 35,883評(píng)論 2 323
  • 正文 我和宋清朗相戀三年阳似,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片铐伴。...
    茶點(diǎn)故事閱讀 37,997評(píng)論 1 333
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡撮奏,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出当宴,到底是詐尸還是另有隱情畜吊,我是刑警寧澤,帶...
    沈念sama閱讀 33,646評(píng)論 4 322
  • 正文 年R本政府宣布即供,位于F島的核電站定拟,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏逗嫡。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,213評(píng)論 3 307
  • 文/蒙蒙 一株依、第九天 我趴在偏房一處隱蔽的房頂上張望驱证。 院中可真熱鬧,春花似錦恋腕、人聲如沸抹锄。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,204評(píng)論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)伙单。三九已至获高,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間吻育,已是汗流浹背念秧。 一陣腳步聲響...
    開封第一講書人閱讀 31,423評(píng)論 1 260
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留布疼,地道東北人摊趾。 一個(gè)月前我還...
    沈念sama閱讀 45,423評(píng)論 2 352
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像游两,于是被迫代替她去往敵國(guó)和親砾层。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,722評(píng)論 2 345

推薦閱讀更多精彩內(nèi)容