Loading... ## 前言 最近项目上线,很多功能还没来得及开发完,遂,又搭建了整套测试系统,大约`17`个项目,用来日常的开发和调试。但是遇到了没有互联网`IP`的尴尬处境,就只能在本地访问,项目之间又涉及到数据互联。前段和后端开发起来进度异常慢,两边的更新改动和数据库有时候都不是同步的,很多时候只是一个小问题,经常就跑偏了,完事就改改改,改完这个,那个又`TM`不行了。持续了半个月,新功能一点进度都没有,大部分时间都花在了改`BUG`和找`BUG`上面了 <img src="https://www.itggg.cn/usr/themes/handsome/assets/img/emotion/aru/blood2.png" class="emotion-aru"> ,但是测试服务器互联网IP又没有。因此迫切的需要把测试系统互联网化,在网上看了一些解决方案和办法,都不太如意。用第三方的吧,不能本地化,始终觉得不安全和稳定。有些又有各种限制,要么就是满足不了需求或者后期难以维护。本着彻底解决的初心,把内外代理,内网穿透这些统统看了个遍,学习了不少新内容。在这里分享给有同样需求的同学 <img src="https://www.itggg.cn/usr/themes/handsome/assets/img/emotion/aru/nose.png" class="emotion-aru"> 。 ## 一些概念<font color='red'>*</font> ### 内网穿透 <svg id="SvgjsSvg1116" preserveAspectRatio="xMinYMin meet" viewBox="30,0,500,400" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" width="100%" height="392.52500915527344"><defs id="SvgjsDefs1117"><pattern id="SvgjsPattern1120" x="0" y="0" width="46.574946720749146" height="46.29355775022534" patternUnits="userSpaceOnUse"><image id="SvgjsImage1121" xlink:href="https://img8.file.cache.docer.com/storage/image/9/3/4/4/5/031b903037dad22548d1c23c461c2250.png/128x128.png" width="46.574946720749146" height="46.29355775022534" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1124" x="0" y="0" width="46.574946720749146" height="46.29355775022534" patternUnits="userSpaceOnUse"><image id="SvgjsImage1125" xlink:href="https://img8.file.cache.docer.com/storage/image/9/3/4/4/5/031b903037dad22548d1c23c461c2250.png/128x128.png" width="46.574946720749146" height="46.29355775022534" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1128" x="0" y="0" width="77.86748904875247" height="70.88701030503256" patternUnits="userSpaceOnUse"><image id="SvgjsImage1129" xlink:href="https://img7.file.cache.docer.com/storage/image/a/6/2/9/6/c3d3a0196b16d3ea2d9fafd79d7e736e.png/128x128.png" width="77.86748904875247" height="70.88701030503256" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1150" x="0" y="0" width="46.574946720749146" height="46.29355775022534" patternUnits="userSpaceOnUse"><image id="SvgjsImage1151" xlink:href="https://img8.file.cache.docer.com/storage/image/5/f/0/5/7/7e395dcdf10dd2dd0b75588e5f6dc67d.png/128x128.png" width="46.574946720749146" height="46.29355775022534" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1154" x="0" y="0" width="46.574946720749146" height="46.29355775022534" patternUnits="userSpaceOnUse"><image id="SvgjsImage1155" xlink:href="https://img8.file.cache.docer.com/storage/image/5/f/0/5/7/7e395dcdf10dd2dd0b75588e5f6dc67d.png/128x128.png" width="46.574946720749146" height="46.29355775022534" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><marker id="SvgjsMarker1158" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1159" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1162" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1163" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1166" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1167" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1170" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1171" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1174" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1175" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1182" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1183" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1190" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1191" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1198" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1199" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1214" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1215" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker></defs><g id="SvgjsG1118" transform="translate(114.733714832993,210.1867355785381)"><path id="SvgjsPath1119" d="M0 0L46.574946720749146 0L46.574946720749146 46.29355775022534L0 46.29355775022534Z " stroke="none" fill="url(#SvgjsPattern1120)"></path></g><g id="SvgjsG1122" transform="translate(446.5802102183307,210.1867355785381)"><path id="SvgjsPath1123" d="M0 0L46.574946720749146 0L46.574946720749146 46.29355775022534L0 46.29355775022534Z " stroke="none" fill="url(#SvgjsPattern1124)"></path></g><g id="SvgjsG1126" transform="translate(272.65189355803307,51.77596765198575)"><path id="SvgjsPath1127" d="M0 0L77.86748904875247 0L77.86748904875247 70.88701030503256L0 70.88701030503256Z " stroke="none" fill="url(#SvgjsPattern1128)"></path></g><g id="SvgjsG1130" transform="translate(221.54762082519363,25.01250457763672)"><path id="SvgjsPath1131" d="M0 4Q0 0 4 0L175.46487612304855 0Q179.46487612304855 0 179.46487612304855 4L179.46487612304855 20.593452554807214Q179.46487612304855 24.593452554807214 175.46487612304855 24.593452554807214L4 24.593452554807214Q0 24.593452554807214 0 20.593452554807214Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1132"><text id="SvgjsText1133" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="126" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="1.1967262774036072" transform="rotate(0)"><tspan id="SvgjsTspan1134" dy="17" x="90.5"><tspan id="SvgjsTspan1135" style="text-decoration:;">外部索引公网服务器</tspan></tspan></text></g></g><g id="SvgjsG1136" transform="translate(25.012496948242188,212.7183979621371)"><path id="SvgjsPath1137" d="M0 4Q0 0 4 0L84.26575079972741 0Q88.26575079972741 0 88.26575079972741 4L88.26575079972741 16.976768355570925Q88.26575079972741 20.976768355570925 84.26575079972741 20.976768355570925L4 20.976768355570925Q0 20.976768355570925 0 16.976768355570925Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1138"><text id="SvgjsText1139" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="58" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-0.6116158222145374" transform="rotate(0)"><tspan id="SvgjsTspan1140" dy="17" x="45"><tspan id="SvgjsTspan1141" style="text-decoration:;">内网NAT</tspan></tspan></text></g></g><g id="SvgjsG1142" transform="translate(494.24674614851483,212.71839796213715)"><path id="SvgjsPath1143" d="M0 4Q0 0 4 0L88.76575079972736 0Q92.76575079972736 0 92.76575079972736 4L92.76575079972736 16.97676835557081Q92.76575079972736 20.97676835557081 88.76575079972736 20.97676835557081L4 20.97676835557081Q0 20.97676835557081 0 16.97676835557081Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1144"><text id="SvgjsText1145" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="58" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-0.6116158222145942" transform="rotate(0)"><tspan id="SvgjsTspan1146" dy="17" x="47"><tspan id="SvgjsTspan1147" style="text-decoration:;">内网NAT</tspan></tspan></text></g></g><g id="SvgjsG1148" transform="translate(112.73243648675319,294.0938090008215)"><path id="SvgjsPath1149" d="M0 0L46.574946720749146 0L46.574946720749146 46.29355775022534L0 46.29355775022534Z " stroke="none" fill="url(#SvgjsPattern1150)"></path></g><g id="SvgjsG1152" transform="translate(444.21506510083503,294.0938090008215)"><path id="SvgjsPath1153" d="M0 0L46.574946720749146 0L46.574946720749146 46.29355775022534L0 46.29355775022534Z " stroke="none" fill="url(#SvgjsPattern1154)"></path></g><g id="SvgjsG1156"><path id="SvgjsPath1157" d="M493.1551569390798 233.33351445365076C526.7313172477733 233.33351445365076 524.3661721302776 317.24058787593424 490.79001182158413 317.24058787593424 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1158)"></path></g><g id="SvgjsG1160"><path id="SvgjsPath1161" d="M444.21506510083503 317.24058787593424C410.63890479214155 317.24058787593424 413.0040499096372 233.33351445365076 446.5802102183307 233.33351445365076 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1162)"></path></g><g id="SvgjsG1164"><path id="SvgjsPath1165" d="M114.733714832993 233.33351445365076C81.16134027220485 233.33351445365076 79.16006192596504 317.24058787593424 112.73243648675319 317.24058787593424 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1166)"></path></g><g id="SvgjsG1168"><path id="SvgjsPath1169" d="M161.30866155374216 233.33351445365076C194.8810361145303 233.33351445365076 192.8797577682905 317.24058787593424 159.30738320750234 317.24058787593424 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1170)"></path></g><g id="SvgjsG1172"><path id="SvgjsPath1173" d="M138.02118819336758 210.1867355785381C138.02118819336758 137.25238203660155 199.7175400160965 87.21947280450206 272.65189355803307 87.21947280450206 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1174)"></path><rect id="SvgjsRect1176" width="65" height="16" x="145.4861582974741" y="113.35272161329388" fill="#ffffff"></rect><text id="SvgjsText1177" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="66" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="111.40272161329388" transform="rotate(0)"><tspan id="SvgjsTspan1178" dy="16" x="177.9861582974741"><tspan id="SvgjsTspan1179" style="text-decoration:;">转发反馈包</tspan></tspan></text></g><g id="SvgjsG1180"><path id="SvgjsPath1181" d="M311.58563808240933 122.66297795701831C311.58563808240933 200.41646164846588 138.02118819336758 132.4332518870906 138.02118819336758 210.1867355785381 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1182)"></path><rect id="SvgjsRect1184" width="52" height="16" x="198.80341313788844" y="158.42485676777824" fill="#ffffff"></rect><text id="SvgjsText1185" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="52" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="156.47485676777825" transform="rotate(0)"><tspan id="SvgjsTspan1186" dy="16" x="224.80341313788844"><tspan id="SvgjsTspan1187" style="text-decoration:;">建立通讯</tspan></tspan></text></g><g id="SvgjsG1188"><path id="SvgjsPath1189" d="M350.51938260678554 87.21947280450206C419.0642171710592 87.21947280450206 469.8676835787053 141.64190101426448 469.8676835787053 210.1867355785381 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1190)"></path><rect id="SvgjsRect1192" width="107" height="16" x="382.39784605434807" y="114.99879122991747" fill="#ffffff"></rect><text id="SvgjsText1193" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="106" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="113.04879122991747" transform="rotate(0)"><tspan id="SvgjsTspan1194" dy="16" x="435.89784605434807"><tspan id="SvgjsTspan1195" style="text-decoration:;">发通知,探测NAT</tspan></tspan></text></g><g id="SvgjsG1196"><path id="SvgjsPath1197" d="M469.8676835787053 210.1867355785381C469.8676835787053 141.64190101426448 419.0642171710592 87.21947280450206 350.51938260678554 87.21947280450206 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1198)"></path></g><g id="SvgjsG1200" transform="translate(102.72611138154986,346.5357133338823)"><path id="SvgjsPath1201" d="M0 4Q0 0 4 0L62.587596931155815 0Q66.58759693115582 0 66.58759693115582 4L66.58759693115582 16.97676835557081Q66.58759693115582 20.97676835557081 62.587596931155815 20.97676835557081L4 20.97676835557081Q0 20.97676835557081 0 16.97676835557081Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1202"><text id="SvgjsText1203" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="42" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-0.6116158222145942" transform="rotate(0)"><tspan id="SvgjsTspan1204" dy="17" x="34"><tspan id="SvgjsTspan1205" style="text-decoration:;">客户端</tspan></tspan></text></g></g><g id="SvgjsG1206" transform="translate(437.11966306134593,346.5357133338823)"><path id="SvgjsPath1207" d="M0 4Q0 0 4 0L69.89283388689626 0Q73.89283388689626 0 73.89283388689626 4L73.89283388689626 16.97676835557081Q73.89283388689626 20.97676835557081 69.89283388689626 20.97676835557081L4 20.97676835557081Q0 20.97676835557081 0 16.97676835557081Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1208"><text id="SvgjsText1209" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="42" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-0.6116158222145942" transform="rotate(0)"><tspan id="SvgjsTspan1210" dy="17" x="37.5"><tspan id="SvgjsTspan1211" style="text-decoration:;">客户端</tspan></tspan></text></g></g><g id="SvgjsG1212"><path id="SvgjsPath1213" d="M446.5802102183307 233.33351445365076C376.7558566965252 233.33351445365076 311.58563808240933 192.48733147882382 311.58563808240933 122.66297795701831 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1214)"></path><rect id="SvgjsRect1216" width="65" height="16" x="320.39879157969295" y="196.1823787760116" fill="#ffffff"></rect><text id="SvgjsText1217" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="66" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="194.23237877601161" transform="rotate(0)"><tspan id="SvgjsTspan1218" dy="16" x="352.89879157969295"><tspan id="SvgjsTspan1219" style="text-decoration:;">发生反馈包</tspan></tspan></text></g><g id="SvgjsG1220" transform="translate(201.0124969482422,249.09380900082152)"><path id="SvgjsPath1221" d="M0 0L207 0L0 0M0 45L207 45L0 45Z " stroke="rgba(50,50,50,1)" stroke-width="2" fill-opacity="1" fill="#ffffff"></path><path id="SvgjsPath1222" d="M0 0L207 0L207 45L0 45L0 0Z " stroke="none" fill="none"></path><g id="SvgjsG1223"><text id="SvgjsText1224" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="52" fill="#323232" font-weight="400" align="middle" font-style="" opacity="1" y="12.55" transform="rotate(0)"><tspan id="SvgjsTspan1225" dy="16" x="104"><tspan id="SvgjsTspan1226" style="text-decoration:;font-weight: bold;">建立通讯</tspan></tspan></text></g></g></svg> 一般个人的电脑一般处于内网环境中,能访问外部网络,但是外部网络却访问不了内部,也就是说外网`ip`只能识别外网`ip`,内网`ip`只能识别内网`ip`。如果想实现外网`ip`识别到内网`ip`,那就需要使用一种技术,**内网穿透**。 简单来说呢,内网穿透是先让内网`ip`先联系上特定的外网`ip`,先建立固定的通道,然后在没有取消的时候一直保持这个通道。所以当前的其他的外网`ip`能访问到这个特定的外网`ip`。顺带着也可以访问到这个建立的通道,那么通过这条通道的,其他的外网`ip`就能访问到个人的机器中。这样就实现了其他外部`ip`访问到我们内部环境的功能,那么这种方式就叫做内网穿透。 <div class="tip inlineBlock warning"> **但是内网穿透的概念很大,很笼统,根据应用场景的不同,所谓的穿透类型也是不一样的,下面是一些个人观点,如有不对,还请大佬留言指教** </div> ### HTTP正向代理 <svg id="SvgjsSvg1253" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" viewBox="50,0,600,300" width="100%" height="242.58750915527344"><defs id="SvgjsDefs1254"><pattern id="SvgjsPattern1257" x="0" y="0" width="51" height="51" patternUnits="userSpaceOnUse"><image id="SvgjsImage1258" xlink:href="https://img7.file.cache.docer.com/storage/image/0/6/c/c/8/adc70b9068cfd8d2c07ab98ec57d8189.png/128x128.png" width="51" height="51" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1261" x="0" y="0" width="56.20001220703125" height="53" patternUnits="userSpaceOnUse"><image id="SvgjsImage1262" xlink:href="https://img8.file.cache.docer.com/storage/image/7/2/7/e/d/3e727a2b2f526d7c75c1d161e9c2b0d8.png/128x128.png" width="56.20001220703125" height="53" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1265" x="0" y="0" width="72" height="75" patternUnits="userSpaceOnUse"><image id="SvgjsImage1266" xlink:href="https://img7.file.cache.docer.com/storage/image/1/a/7/5/d/19e71e0caa41d04e70faec9d564bf5d3.png/128x128.png" width="72" height="75" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1269" x="0" y="0" width="64" height="64" patternUnits="userSpaceOnUse"><image id="SvgjsImage1270" xlink:href="https://img8.file.cache.docer.com/storage/image/e/2/8/2/7/bb5cec7a27d4f5108fab09b423188673.png/128x128.png" width="64" height="64" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1273" x="0" y="0" width="64" height="64" patternUnits="userSpaceOnUse"><image id="SvgjsImage1274" xlink:href="https://img7.file.cache.docer.com/storage/image/1/f/2/d/6/e9e71dfdf61a9bc4282887efd747ef6c.png/128x128.png" width="64" height="64" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><marker id="SvgjsMarker1277" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1278" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1285" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1286" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1293" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1294" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1301" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1302" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1309" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1310" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1317" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1318" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1325" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1326" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1333" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1334" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1341" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1342" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker></defs><g id="SvgjsG1255" transform="translate(495.56248474121094,80.91250610351562)"><path id="SvgjsPath1256" d="M0 0L51 0L51 51L0 51Z " stroke="none" fill="url(#SvgjsPattern1257)"></path></g><g id="SvgjsG1259" transform="translate(626.7205812866213,83.87542962395491)"><path id="SvgjsPath1260" d="M0 0L56.20001220703125 0L56.20001220703125 53L0 53Z " stroke="none" fill="url(#SvgjsPattern1261)"></path></g><g id="SvgjsG1263" transform="translate(34.0625,67.91250610351562)"><path id="SvgjsPath1264" d="M0 0L72 0L72 75L0 75Z " stroke="none" fill="url(#SvgjsPattern1265)"></path></g><g id="SvgjsG1267" transform="translate(195.0625,67.91250610351562)"><path id="SvgjsPath1268" d="M0 0L64 0L64 64L0 64Z " stroke="none" fill="url(#SvgjsPattern1269)"></path></g><g id="SvgjsG1271" transform="translate(354.0625,67.91250610351562)"><path id="SvgjsPath1272" d="M0 0L64 0L64 64L0 64Z " stroke="none" fill="url(#SvgjsPattern1273)"></path></g><g id="SvgjsG1275"><path id="SvgjsPath1276" d="M70.0625 67.91250610351562C121.86248779296875 53.01250457763672 170.86248779296875 42.01250457763672 227.0625 67.91250610351562 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1277)"></path><rect id="SvgjsRect1279" width="26" height="16" x="133.91249084472656" y="44.612504959106445" fill="#ffffff"></rect><text id="SvgjsText1280" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="26" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="42.66250495910644" transform="rotate(0)"><tspan id="SvgjsTspan1281" dy="16" x="146.91249084472656"><tspan id="SvgjsTspan1282" style="text-decoration:;">请求</tspan></tspan></text></g><g id="SvgjsG1283"><path id="SvgjsPath1284" d="M227.0625 67.91250610351562C280.86248779296875 40.01250457763672 350.86248779296875 50.01250457763672 386.0625 67.91250610351562 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1285)"></path><rect id="SvgjsRect1287" width="26" height="16" x="300.53749084472656" y="42.737504959106445" fill="#ffffff"></rect><text id="SvgjsText1288" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="26" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="40.78750495910644" transform="rotate(0)"><tspan id="SvgjsTspan1289" dy="16" x="313.53749084472656"><tspan id="SvgjsTspan1290" style="text-decoration:;">请求</tspan></tspan></text></g><g id="SvgjsG1291"><path id="SvgjsPath1292" d="M386.0625 67.91250610351562C420.86248779296875 34.01250457763672 598.8624877929688 25.01250457763672 654.8205873901369 83.87542962395491 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1293)"></path><rect id="SvgjsRect1295" width="26" height="16" x="499.5072517684937" y="33.10787039916136" fill="#ffffff"></rect><text id="SvgjsText1296" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="26" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="31.157870399161357" transform="rotate(0)"><tspan id="SvgjsTspan1297" dy="16" x="512.5072517684937"><tspan id="SvgjsTspan1298" style="text-decoration:;">请求</tspan></tspan></text></g><g id="SvgjsG1299"><path id="SvgjsPath1300" d="M658.820587390137 157.02378131856494C579.8624877929688 218.01250457763672 427.86248779296875 188.01250457763672 383.0625 159.41250610351562 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1301)"></path><rect id="SvgjsRect1303" width="26" height="16" x="495.1322517684937" y="183.8139143609876" fill="#ffffff"></rect><text id="SvgjsText1304" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="26" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="181.86391436098762" transform="rotate(0)"><tspan id="SvgjsTspan1305" dy="16" x="508.1322517684937"><tspan id="SvgjsTspan1306" style="text-decoration:;">响应</tspan></tspan></text></g><g id="SvgjsG1307"><path id="SvgjsPath1308" d="M383.0625 159.41250610351562C344.86248779296875 198.01250457763672 277.86248779296875 200.01250457763672 233.06248474121094 159.41250610351562 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1309)"></path><rect id="SvgjsRect1311" width="26" height="16" x="297.53748893737793" y="181.11250495910645" fill="#ffffff"></rect><text id="SvgjsText1312" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="26" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="179.16250495910646" transform="rotate(0)"><tspan id="SvgjsTspan1313" dy="16" x="310.53748893737793"><tspan id="SvgjsTspan1314" style="text-decoration:;">响应</tspan></tspan></text></g><g id="SvgjsG1315"><path id="SvgjsPath1316" d="M233.06248474121094 159.41250610351562C206.46249389648438 180.0124969482422 153.46249389648438 190.0124969482422 115.12062095947289 146.94960547125993 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1317)"></path><rect id="SvgjsRect1319" width="26" height="16" x="165.49475863494877" y="169.05463665802858" fill="#ffffff"></rect><text id="SvgjsText1320" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="26" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="167.1046366580286" transform="rotate(0)"><tspan id="SvgjsTspan1321" dy="16" x="178.49475863494877"><tspan id="SvgjsTspan1322" style="text-decoration:;">响应</tspan></tspan></text></g><g id="SvgjsG1323"><path id="SvgjsPath1324" d="M106.0625 105.41250610351562C141.7304127508185 105.41250610351562 159.3945872491815 99.91250610351562 195.0625 99.91250610351562 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1325)"></path><rect id="SvgjsRect1327" width="43" height="16" x="129.0625" y="94.66250610351562" fill="#ffffff"></rect><text id="SvgjsText1328" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="43" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="92.71250610351562" transform="rotate(0)"><tspan id="SvgjsTspan1329" dy="16" x="150.5625"><tspan id="SvgjsTspan1330" style="text-decoration:;">HTTP1</tspan></tspan></text></g><g id="SvgjsG1331"><path id="SvgjsPath1332" d="M259.0625 99.91250610351562C297.0625 99.91250610351562 316.0625 99.91250610351562 354.0625 99.91250610351562 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1333)"></path><rect id="SvgjsRect1335" width="43" height="16" x="285.0625" y="91.91250610351562" fill="#ffffff"></rect><text id="SvgjsText1336" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="43" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="89.96250610351562" transform="rotate(0)"><tspan id="SvgjsTspan1337" dy="16" x="306.5625"><tspan id="SvgjsTspan1338" style="text-decoration:;">HTTP2</tspan></tspan></text></g><g id="SvgjsG1339"><path id="SvgjsPath1340" d="M418.0625 99.91250610351562C500.86248779296875 25.01250457763672 564.8624877929688 82.01250457763672 626.7205812866213 110.37542962395491 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1341)"></path><rect id="SvgjsRect1343" width="43" height="16" x="508.74475100555424" y="58.42037039916136" fill="#ffffff"></rect><text id="SvgjsText1344" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="43" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="56.470370399161354" transform="rotate(0)"><tspan id="SvgjsTspan1345" dy="16" x="530.2447510055542"><tspan id="SvgjsTspan1346" style="text-decoration:;">HTTP1</tspan></tspan></text></g><g id="SvgjsG1347" transform="translate(25.004379040527112,136.87542962395491)"><path id="SvgjsPath1348" d="M0 4Q0 0 4 0L86.11624191894578 0Q90.11624191894578 0 90.11624191894578 4L90.11624191894578 16.148351694610028Q90.11624191894578 20.148351694610028 86.11624191894578 20.148351694610028L4 20.148351694610028Q0 20.148351694610028 0 16.148351694610028Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1349"><text id="SvgjsText1350" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="42" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.025824152694986" transform="rotate(0)"><tspan id="SvgjsTspan1351" dy="17" x="46"><tspan id="SvgjsTspan1352" style="text-decoration:;">浏览器</tspan></tspan></text></g></g><g id="SvgjsG1353" transform="translate(176.80435157470674,134.91250610351562)"><path id="SvgjsPath1354" d="M0 4Q0 0 4 0L106.058136218262 0Q110.058136218262 0 110.058136218262 4L110.058136218262 20.074198735488608Q110.058136218262 24.074198735488608 106.058136218262 24.074198735488608L4 24.074198735488608Q0 24.074198735488608 0 20.074198735488608Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1355"><text id="SvgjsText1356" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="84" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="0.9370993677443038" transform="rotate(0)"><tspan id="SvgjsTspan1357" dy="17" x="56"><tspan id="SvgjsTspan1358" style="text-decoration:;">互联网服务器</tspan></tspan></text></g></g><g id="SvgjsG1359" transform="translate(338.80435157470674,136.87542962395491)"><path id="SvgjsPath1360" d="M0 4Q0 0 4 0L86.11624191894578 0Q90.11624191894578 0 90.11624191894578 4L90.11624191894578 16.148351694610028Q90.11624191894578 20.148351694610028 86.11624191894578 20.148351694610028L4 20.148351694610028Q0 20.148351694610028 0 16.148351694610028Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1361"><text id="SvgjsText1362" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="56" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.025824152694986" transform="rotate(0)"><tspan id="SvgjsTspan1363" dy="17" x="46"><tspan id="SvgjsTspan1364" style="text-decoration:;">项目内网</tspan></tspan></text></g></g><g id="SvgjsG1365" transform="translate(466.5543668334958,136.41250610351562)"><path id="SvgjsPath1366" d="M0 4Q0 0 4 0L105.01623581543015 0Q109.01623581543015 0 109.01623581543015 4L109.01623581543015 17.074198735488608Q109.01623581543015 21.074198735488608 105.01623581543015 21.074198735488608L4 21.074198735488608Q0 21.074198735488608 0 17.074198735488608Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1367"><text id="SvgjsText1368" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="84" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-0.5629006322556962" transform="rotate(0)"><tspan id="SvgjsTspan1369" dy="17" x="55.5"><tspan id="SvgjsTspan1370" style="text-decoration:;">运营商防火墙</tspan></tspan></text></g></g><g id="SvgjsG1371" transform="translate(613.7624664306641,136.87542962395491)"><path id="SvgjsPath1372" d="M0 4Q0 0 4 0L86.11624191894578 0Q90.11624191894578 0 90.11624191894578 4L90.11624191894578 16.148351694610028Q90.11624191894578 20.148351694610028 86.11624191894578 20.148351694610028L4 20.148351694610028Q0 20.148351694610028 0 16.148351694610028Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1373"><text id="SvgjsText1374" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="70" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.025824152694986" transform="rotate(0)"><tspan id="SvgjsTspan1375" dy="17" x="46"><tspan id="SvgjsTspan1376" style="text-decoration:;">内网服务器</tspan></tspan></text></g></g></svg> 这张网络拓扑图解释了内网代理的原理,由于内网(通常情况是家里的有线宽带)没有公网`IP`,无法在路由器上做端口映射,或者利用动态`DNS`连接回家里的设备,所以需要一个具有公网`IP`的设备来进行传递数据,公网`IP`设备和家里的能够建立一个稳定的隧道。 有公网IP的设备称为服务端,没有公网`IP`的内网设备称为客户端,一般是家里的设备,可能是路由器、`NAS`、树莓派等。 **数据流的传递方向**:外网设备 - 服务端 - 客户端(内网设备) #### 功能场景 > - **把处于内网环境的Web,在外网访问** > - **在外网远程桌面连接内网的机器** ### Socks5代理 <svg id="SvgjsSvg1000" preserveAspectRatio="xMinYMin meet" viewBox="0,0,500,300" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" width="100%" height="311.53749084472656"><defs id="SvgjsDefs1001"><pattern id="SvgjsPattern1009" x="0" y="0" width="64" height="64" patternUnits="userSpaceOnUse"><image id="SvgjsImage1010" xlink:href="https://img7.file.cache.docer.com/storage/image/1/a/7/5/d/19e71e0caa41d04e70faec9d564bf5d3.png/128x128.png" width="64" height="64" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1013" x="0" y="0" width="64" height="64" patternUnits="userSpaceOnUse"><image id="SvgjsImage1014" xlink:href="https://img8.file.cache.docer.com/storage/image/9/3/4/4/5/031b903037dad22548d1c23c461c2250.png/128x128.png" width="64" height="64" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1017" x="0" y="0" width="64" height="64" patternUnits="userSpaceOnUse"><image id="SvgjsImage1018" xlink:href="https://img8.file.cache.docer.com/storage/image/9/3/4/4/5/031b903037dad22548d1c23c461c2250.png/128x128.png" width="64" height="64" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1021" x="0" y="0" width="64" height="64" patternUnits="userSpaceOnUse"><image id="SvgjsImage1022" xlink:href="https://img8.file.cache.docer.com/storage/image/e/2/8/2/7/bb5cec7a27d4f5108fab09b423188673.png/128x128.png" width="64" height="64" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><marker id="SvgjsMarker1025" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1026" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1033" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1034" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1041" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1042" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1049" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1050" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1057" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1058" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1065" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1066" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><pattern id="SvgjsPattern1073" x="0" y="0" width="56" height="50.9999885559082" patternUnits="userSpaceOnUse"><image id="SvgjsImage1074" xlink:href="https://img7.file.cache.docer.com/storage/image/0/6/c/c/8/adc70b9068cfd8d2c07ab98ec57d8189.png/128x128.png" width="56" height="50.9999885559082" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><marker id="SvgjsMarker1077" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1078" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1085" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1086" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker></defs><g id="SvgjsG1007" transform="translate(50.625,55.01249694824219)"><path id="SvgjsPath1008" d="M0 0L64 0L64 64L0 64Z " stroke="none" fill="url(#SvgjsPattern1009)"></path></g><g id="SvgjsG1011" transform="translate(150.625,180.0124969482422)"><path id="SvgjsPath1012" d="M0 0L64 0L64 64L0 64Z " stroke="none" fill="url(#SvgjsPattern1013)"></path></g><g id="SvgjsG1015" transform="translate(332.625,180.0124969482422)"><path id="SvgjsPath1016" d="M0 0L64 0L64 64L0 64Z " stroke="none" fill="url(#SvgjsPattern1017)"></path></g><g id="SvgjsG1019" transform="translate(430.625,61.01249694824219)"><path id="SvgjsPath1020" d="M0 0L64 0L64 64L0 64Z " stroke="none" fill="url(#SvgjsPattern1021)"></path></g><g id="SvgjsG1023"><path id="SvgjsPath1024" d="M114.625 87.01249694824219L182.625 87.01249694824219L182.625 180.0124969482422 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1025)"></path><rect id="SvgjsRect1027" width="78" height="16" x="143.625" y="91.51249694824219" fill="#ffffff"></rect><text id="SvgjsText1028" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="77" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="89.56249694824218" transform="rotate(0)"><tspan id="SvgjsTspan1029" dy="16" x="182.625"><tspan id="SvgjsTspan1030" style="text-decoration:;">TCP代理连接</tspan></tspan></text></g><g id="SvgjsG1031"><path id="SvgjsPath1032" d="M82.625 119.01249694824219L82.625 212.0124969482422L150.625 212.0124969482422 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1033)"></path><rect id="SvgjsRect1035" width="78" height="16" x="43.625" y="191.5124969482422" fill="#ffffff"></rect><text id="SvgjsText1036" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="77" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="189.5624969482422" transform="rotate(0)"><tspan id="SvgjsTspan1037" dy="16" x="82.625"><tspan id="SvgjsTspan1038" style="text-decoration:;">TCP代理连接</tspan></tspan></text></g><g id="SvgjsG1039"><path id="SvgjsPath1040" d="M182.625 180.0124969482422C213.625 143.0124969482422 338.625 143.0124969482422 364.625 180.0124969482422 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1041)"></path><rect id="SvgjsRect1043" width="47" height="16" x="252" y="144.2624969482422" fill="#ffffff"></rect><text id="SvgjsText1044" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="47" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="142.3124969482422" transform="rotate(0)"><tspan id="SvgjsTspan1045" dy="16" x="275.5"><tspan id="SvgjsTspan1046" style="text-decoration:;">ssh代理</tspan></tspan></text></g><g id="SvgjsG1047"><path id="SvgjsPath1048" d="M364.625 180.0124969482422L364.625 93.01249694824219L430.625 93.01249694824219 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1049)"></path><rect id="SvgjsRect1051" width="62" height="16" x="333.625" y="95.51249694824219" fill="#ffffff"></rect><text id="SvgjsText1052" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="61" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="93.56249694824218" transform="rotate(0)"><tspan id="SvgjsTspan1053" dy="16" x="364.625"><tspan id="SvgjsTspan1054" style="text-decoration:;">HTTP请求</tspan></tspan></text></g><g id="SvgjsG1055"><path id="SvgjsPath1056" d="M396.625 212.0124969482422L462.625 212.0124969482422L462.625 125.01249694824219 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1057)"></path><rect id="SvgjsRect1059" width="62" height="16" x="431.625" y="193.5124969482422" fill="#ffffff"></rect><text id="SvgjsText1060" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="61" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="191.5624969482422" transform="rotate(0)"><tspan id="SvgjsTspan1061" dy="16" x="462.625"><tspan id="SvgjsTspan1062" style="text-decoration:;">HTTP回应</tspan></tspan></text></g><g id="SvgjsG1063"><path id="SvgjsPath1064" d="M364.625 244.0124969482422C329.625 269.0124969482422 228.625 287.0124969482422 182.625 244.0124969482422 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1065)"></path><rect id="SvgjsRect1067" width="52" height="16" x="251.75" y="261.5124969482422" fill="#ffffff"></rect><text id="SvgjsText1068" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="52" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="259.5624969482422" transform="rotate(0)"><tspan id="SvgjsTspan1069" dy="16" x="277.75"><tspan id="SvgjsTspan1070" style="text-decoration:;">返回数据</tspan></tspan></text></g><g id="SvgjsG1071" transform="translate(252.625,48.01249694824219)"><path id="SvgjsPath1072" d="M0 0L56 0L56 50.9999885559082L0 50.9999885559082Z " stroke="none" fill="url(#SvgjsPattern1073)"></path></g><g id="SvgjsG1075"><path id="SvgjsPath1076" d="M252.625 73.51249122619629C197.16149826490175 73.51249122619629 170.08850173509825 87.01249694824219 114.625 87.01249694824219 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1077)"></path><rect id="SvgjsRect1079" width="26" height="16" x="170.625" y="72.26249408721924" fill="#ffffff"></rect><text id="SvgjsText1080" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="26" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="70.31249408721924" transform="rotate(0)"><tspan id="SvgjsTspan1081" dy="16" x="183.625"><tspan id="SvgjsTspan1082" style="text-decoration:;">阻断</tspan></tspan></text></g><g id="SvgjsG1083"><path id="SvgjsPath1084" d="M308.625 73.51249122619629C358.0444297387735 73.51249122619629 381.2055702612265 93.01249694824219 430.625 93.01249694824219 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1085)"></path><rect id="SvgjsRect1087" width="26" height="16" x="356.625" y="75.26249408721924" fill="#ffffff"></rect><text id="SvgjsText1088" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="26" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="73.31249408721924" transform="rotate(0)"><tspan id="SvgjsTspan1089" dy="16" x="369.625"><tspan id="SvgjsTspan1090" style="text-decoration:;">阻断</tspan></tspan></text></g><g id="SvgjsG1091" transform="translate(232.62498474121094,25.012474060058594)"><path id="SvgjsPath1092" d="M0 0L89 0L89 20L0 20Z " stroke="none" fill="none"></path><g id="SvgjsG1093"><text id="SvgjsText1094" font-family="微软雅黑" text-anchor="middle" font-size="15px" width="45" fill="#323232" font-weight="400" align="middle" font-style="" opacity="1" y="-1.25" transform="rotate(0)"><tspan id="SvgjsTspan1095" dy="18" x="45"><tspan id="SvgjsTspan1096" style="text-decoration:;font-weight: bold;">一面墙</tspan></tspan></text></g></g><g id="SvgjsG1097" transform="translate(34.99210934134726,245.02407843818133)"><path id="SvgjsPath1098" d="M0 4Q0 0 4 0L132.63289065865274 0Q136.63289065865274 0 136.63289065865274 4L136.63289065865274 28.488407065969056Q136.63289065865274 32.48840706596906 132.63289065865274 32.48840706596906L4 32.48840706596906Q0 32.48840706596906 0 28.488407065969056Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1099"><text id="SvgjsText1100" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="103" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="5.144203532984529" transform="rotate(0)"><tspan id="SvgjsTspan1101" dy="17" x="69"><tspan id="SvgjsTspan1102" style="text-decoration:;">socks5本地代理</tspan></tspan></text></g></g><g id="SvgjsG1103" transform="translate(385.3925466796866,246.1199073883722)"><path id="SvgjsPath1104" d="M0 4Q0 0 4 0L111.23245332031343 0Q115.23245332031343 0 115.23245332031343 4L115.23245332031343 26.296749165587187Q115.23245332031343 30.296749165587187 111.23245332031343 30.296749165587187L4 30.296749165587187Q0 30.296749165587187 0 26.296749165587187Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1105"><text id="SvgjsText1106" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="70" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="4.048374582793594" transform="rotate(0)"><tspan id="SvgjsTspan1107" dy="17" x="58.5"><tspan id="SvgjsTspan1108" style="text-decoration:;">国外服务器</tspan></tspan></text></g></g><g id="SvgjsG1109" transform="translate(25.008773339843287,25.012474060058594)"><path id="SvgjsPath1110" d="M0 4Q0 0 4 0L111.23245332031343 0Q115.23245332031343 0 115.23245332031343 4L115.23245332031343 26.296749165587187Q115.23245332031343 30.296749165587187 111.23245332031343 30.296749165587187L4 30.296749165587187Q0 30.296749165587187 0 26.296749165587187Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1111"><text id="SvgjsText1112" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="42" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="4.048374582793594" transform="rotate(0)"><tspan id="SvgjsTspan1113" dy="17" x="58.5"><tspan id="SvgjsTspan1114" style="text-decoration:;">浏览器</tspan></tspan></text></g></g><g id="SvgjsG1115" transform="translate(413.5087580810542,25.012474060058594)"><path id="SvgjsPath1116" d="M0 4Q0 0 4 0L111.23245332031343 0Q115.23245332031343 0 115.23245332031343 4L115.23245332031343 26.296749165587187Q115.23245332031343 30.296749165587187 111.23245332031343 30.296749165587187L4 30.296749165587187Q0 30.296749165587187 0 26.296749165587187Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1117"><text id="SvgjsText1118" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="88" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="4.048374582793594" transform="rotate(0)"><tspan id="SvgjsTspan1119" dy="17" x="58.5"><tspan id="SvgjsTspan1120" style="text-decoration:;">Google Web</tspan></tspan></text></g></g></svg> #### 功能场景 > - **将公网服务器1.1.1.1的8003端口作为socks5代理,达到访问内网任意设备或者资源的效果** > - **在外网环境下如同使用VPN一样访问内网设备或者资源** > - **科学上网** #### 什么是SOCKS5协议 `SOCKS`是一种网络传输协议,主要用于客户端与外网服务器之间通讯的中间传递。`SOCKS`是`"Sockets”`的缩写。 当防火墙后的客户端要访问外部的服务器时,就跟`SOCKS`代理服务器连接。这个代理服务器控制客户端访问外网的资格,允许的话,就将客户端的请求发往外部的服务器。这个协议最初由`David Koblas`开发,而后由`NEC的Ying-Da Lee`将其扩展到版本4。最新协议是版本5,与前一版本相比,增加支持`UDP`、验证,以及`IPv6`。根据`OSI`模型,`SOCKS`是会话层的协议,位于表示层与传输层之间。 #### SOCKS5代理与HTTP代理区别 `SOCKS`工作在比HTTP代理更低的层次:`SOCKS`使用握手协议来通知代理软件其客户端试图进行的连接`SOCKS`,然后尽可能透明地进行操作,而常规代理可能会解释和重写报头(例如,使用另一种底层协议,例如FTP;然而,`HTTP`代理只是将`HTTP`请求转发到所需的`HTTP`服务器)。虽然`HTTP`代理有不同的使用模式,`CONNECT`方法允许转发`TCP`连接;然而,`SOCKS`代理还可以转发`UDP`流量和反向代理,而`HTTP`代理不能。`HTTP`代理通常更了解`HTTP`协议,执行更高层次的过滤(虽然通常只用于`GET`和`POST`方法,而不用于`CONNECT`方法) #### SOCKS5代理和VPN区别 `virtual private network`(虚拟专网),你接入`VPN`就是接入了一个专有网络,那么你访问网络都是从这个专有网络的出口出去,好比你在家,你家路由器后面的网络设备是在同一个网络,而`VPN`则是让你的设备进入了另一个网络。同时你的`IP`地址也变成了由`VPN`分配的一个`IP`地址。通常是一个私网地址。你和`VPN`服务器之间的通信是否加密取决于连接`VPN`的具体方式/协议。 `Sock5`代理服务器则是把你的网络数据请求通过一条连接你和代理服务器之间的通道,由服务器转发到目的地。你没有加入任何新的网络,只是`http/socks`数据经过代理服务器的转发送出,并从代理服务器接收回应。你与代理服务器通信过程不会被额外处理,如果你用https,那本身就是加密的。 #### Shadowsocks全局模式与PAC模式区别 `PAC`模式就是会在你连接网站的时候读取`PAC`文件里的规则,来确定你访问的网站有没有被墙,如果符合,那就会使用代理服务器连接网站,而`PAC`列表一般都是从`GFWList`更新的。`GFWList`定期会更新被墙的网站(不过一般挺慢的) 简单地说,在全局模式下,所有网站默认走代理。而`PAC`模式是只有被墙的才会走代理,推荐`PAC`模式,如果`PAC`模式无法访问一些网站,就换全局模式试试,一般是因为`PAC`更新不及时(也可能是`GFWList`更新不及时)导致的。 ### P2P穿透 <svg id="SvgjsSvg1104" preserveAspectRatio="xMinYMin meet" viewBox="100,80,500,200" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" width="100%" height="424.2624816894531"><defs id="SvgjsDefs1105"><pattern id="SvgjsPattern1108" x="0" y="0" width="100%" height="46.29355775022534" patternUnits="userSpaceOnUse"><image id="SvgjsImage1109" xlink:href="https://img8.file.cache.docer.com/storage/image/5/f/0/5/7/7e395dcdf10dd2dd0b75588e5f6dc67d.png/128x128.png" width="46.574946720749146" height="46.29355775022534" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1112" x="0" y="0" width="46.574946720749146" height="46.29355775022534" patternUnits="userSpaceOnUse"><image id="SvgjsImage1113" xlink:href="https://img8.file.cache.docer.com/storage/image/5/f/0/5/7/7e395dcdf10dd2dd0b75588e5f6dc67d.png/128x128.png" width="46.574946720749146" height="46.29355775022534" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1116" x="0" y="0" width="64" height="64" patternUnits="userSpaceOnUse"><image id="SvgjsImage1117" xlink:href="https://img8.file.cache.docer.com/storage/image/f/6/5/d/1/695df7776400535a568c6391d670e01b.png/128x128.png" width="64" height="64" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><marker id="SvgjsMarker1120" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1121" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1128" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1129" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1161" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1162" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1165" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1166" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><pattern id="SvgjsPattern1169" x="0" y="0" width="64" height="64" patternUnits="userSpaceOnUse"><image id="SvgjsImage1170" xlink:href="https://img8.file.cache.docer.com/storage/image/4/a/7/4/7/92884bfba5b1dca775689ca749772a73.png/128x128.png" width="64" height="64" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1173" x="0" y="0" width="64" height="64" patternUnits="userSpaceOnUse"><image id="SvgjsImage1174" xlink:href="https://img8.file.cache.docer.com/storage/image/4/a/7/4/7/92884bfba5b1dca775689ca749772a73.png/128x128.png" width="64" height="64" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><marker id="SvgjsMarker1189" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1190" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1193" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1194" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1197" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1198" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1201" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1202" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker></defs><g id="SvgjsG1106" transform="translate(134.0375083290786,327.19069976258265)"><path id="SvgjsPath1107" d="M0 0L46.574946720749146 0L46.574946720749146 46.29355775022534L0 46.29355775022534Z " stroke="none" fill="url(#SvgjsPattern1108)"></path></g><g id="SvgjsG1110" transform="translate(481.8249969482422,327.19069976258265)"><path id="SvgjsPath1111" d="M0 0L46.574946720749146 0L46.574946720749146 46.29355775022534L0 46.29355775022534Z " stroke="none" fill="url(#SvgjsPattern1112)"></path></g><g id="SvgjsG1114" transform="translate(280.57498550415033,144.3375015258789)"><path id="SvgjsPath1115" d="M0 0L64 0L64 64L0 64Z " stroke="none" fill="url(#SvgjsPattern1116)"></path></g><g id="SvgjsG1118"><path id="SvgjsPath1119" d="M312.57498550415033 144.3375015258789C312.57498550415033 24.99503422312921 647.742410971741 350.3374786376953 528.3999436689913 350.3374786376953 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1120)"></path><rect id="SvgjsRect1122" width="26" height="16" x="452.240889825102" y="194.584064843256" fill="#ffffff"></rect><text id="SvgjsText1123" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="26" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="192.634064843256" transform="rotate(0)"><tspan id="SvgjsTspan1124" dy="16" x="465.240889825102"><tspan id="SvgjsTspan1125" style="text-decoration:;">中转</tspan></tspan></text></g><g id="SvgjsG1126"><path id="SvgjsPath1127" d="M312.57498550415033 144.3375015258789C312.57498550415033 35.29686959366154 24.99687639686124 350.3374786376953 134.0375083290786 350.3374786376953 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1128)"></path><rect id="SvgjsRect1130" width="26" height="16" x="169.41600994203299" y="198.4472531072056" fill="#ffffff"></rect><text id="SvgjsText1131" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="26" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="196.4972531072056" transform="rotate(0)"><tspan id="SvgjsTspan1132" dy="16" x="182.41600994203299"><tspan id="SvgjsTspan1133" style="text-decoration:;">中转</tspan></tspan></text></g><g id="SvgjsG1134" transform="translate(280.57498550415033,345.484257512808)"><path id="SvgjsPath1135" d="M0 0L126.50002288818371 0L0 0M0 20L126.50002288818371 20L0 20Z " stroke="rgba(50,50,50,1)" stroke-width="2" fill-opacity="1" fill="#ffffff"></path><path id="SvgjsPath1136" d="M0 0L126.50002288818371 0L126.50002288818371 20L0 20L0 0Z " stroke="none" fill="none"></path><g id="SvgjsG1137"><text id="SvgjsText1138" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="77" fill="#323232" font-weight="400" align="middle" font-style="" opacity="1" y="0.050000000000000044" transform="rotate(0)"><tspan id="SvgjsTspan1139" dy="16" x="64"><tspan id="SvgjsTspan1140" style="text-decoration:;font-weight: bold;">P2P通道直连</tspan></tspan></text></g></g><g id="SvgjsG1141" transform="translate(101.2668607299803,369.2633027903903)"><path id="SvgjsPath1142" d="M0 4Q0 0 4 0L86.11624191894578 0Q90.11624191894578 0 90.11624191894578 4L90.11624191894578 16.148351694610028Q90.11624191894578 20.148351694610028 86.11624191894578 20.148351694610028L4 20.148351694610028Q0 20.148351694610028 0 16.148351694610028Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1143"><text id="SvgjsText1144" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="53" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.025824152694986" transform="rotate(0)"><tspan id="SvgjsTspan1145" dy="17" x="46"><tspan id="SvgjsTspan1146" style="text-decoration:;">客户端A</tspan></tspan></text></g></g><g id="SvgjsG1147" transform="translate(456.2668607299802,378.2633027903903)"><path id="SvgjsPath1148" d="M0 4Q0 0 4 0L86.11624191894578 0Q90.11624191894578 0 90.11624191894578 4L90.11624191894578 16.148351694610028Q90.11624191894578 20.148351694610028 86.11624191894578 20.148351694610028L4 20.148351694610028Q0 20.148351694610028 0 16.148351694610028Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1149"><text id="SvgjsText1150" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="51" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.025824152694986" transform="rotate(0)"><tspan id="SvgjsTspan1151" dy="17" x="46"><tspan id="SvgjsTspan1152" style="text-decoration:;">客户端B</tspan></tspan></text></g></g><g id="SvgjsG1153" transform="translate(267.51686454467745,93.2633027903903)"><path id="SvgjsPath1154" d="M0 4Q0 0 4 0L86.11624191894578 0Q90.11624191894578 0 90.11624191894578 4L90.11624191894578 16.148351694610028Q90.11624191894578 20.148351694610028 86.11624191894578 20.148351694610028L4 20.148351694610028Q0 20.148351694610028 0 16.148351694610028Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1155"><text id="SvgjsText1156" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="42" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.025824152694986" transform="rotate(0)"><tspan id="SvgjsTspan1157" dy="17" x="46"><tspan id="SvgjsTspan1158" style="text-decoration:;">服务器</tspan></tspan></text></g></g><g id="SvgjsG1159"><path id="SvgjsPath1160" d="M406.2641108890336 355.48428040099157C436.5584986740828 355.48428040099157 451.53060916319293 350.3374786376953 481.8249969482422 350.3374786376953 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1161)"></path></g><g id="SvgjsG1163"><path id="SvgjsPath1164" d="M280.57499787746434 352.48428040099157C240.5807608398551 352.48428040099157 220.606692087437 350.3374786376953 180.61245504982776 350.3374786376953 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1165)"></path></g><g id="SvgjsG1167" transform="translate(381.82499694824224,223.80120001197508)"><path id="SvgjsPath1168" d="M0 0L64 0L64 64L0 64Z " stroke="none" fill="url(#SvgjsPattern1169)"></path></g><g id="SvgjsG1171" transform="translate(195.04592883911118,221.3375015258789)"><path id="SvgjsPath1172" d="M0 0L64 0L64 64L0 64Z " stroke="none" fill="url(#SvgjsPattern1173)"></path></g><g id="SvgjsG1175" transform="translate(197.26686072998018,272.8012000119751)"><path id="SvgjsPath1176" d="M0 4Q0 0 4 0L55.55813621826201 0Q59.55813621826201 0 59.55813621826201 4L59.55813621826201 14.927396972192355Q59.55813621826201 18.927396972192355 55.55813621826201 18.927396972192355L4 18.927396972192355Q0 18.927396972192355 0 14.927396972192355Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1177"><text id="SvgjsText1178" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="31" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.6363015139038226" transform="rotate(0)"><tspan id="SvgjsTspan1179" dy="17" x="30.5"><tspan id="SvgjsTspan1180" style="text-decoration:;">NAT</tspan></tspan></text></g></g><g id="SvgjsG1181" transform="translate(384.04592883911124,276.8012000119751)"><path id="SvgjsPath1182" d="M0 4Q0 0 4 0L55.55813621826201 0Q59.55813621826201 0 59.55813621826201 4L59.55813621826201 14.927396972192355Q59.55813621826201 18.927396972192355 55.55813621826201 18.927396972192355L4 18.927396972192355Q0 18.927396972192355 0 14.927396972192355Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1183"><text id="SvgjsText1184" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="31" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.6363015139038226" transform="rotate(0)"><tspan id="SvgjsTspan1185" dy="17" x="30.5"><tspan id="SvgjsTspan1186" style="text-decoration:;">NAT</tspan></tspan></text></g></g><g id="SvgjsG1187"><path id="SvgjsPath1188" d="M157.32498168945318 327.19069976258265C157.32498168945318 294.0192307118284 161.87445978835697 253.3375015258789 195.04592883911118 253.3375015258789 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1189)"></path></g><g id="SvgjsG1191"><path id="SvgjsPath1192" d="M259.0459288391112 253.3375015258789C291.02717404535406 253.3375015258789 248.5937402979074 176.3375015258789 280.57498550415033 176.3375015258789 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1193)"></path></g><g id="SvgjsG1195"><path id="SvgjsPath1196" d="M505.1124703086167 327.19069976258265C505.1124703086167 290.0715075901248 482.9441891207001 255.80120001197508 445.8249969482422 255.80120001197508 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1197)"></path></g><g id="SvgjsG1199"><path id="SvgjsPath1200" d="M381.82499694824224 255.80120001197508C346.72048389439306 255.80120001197508 379.6794985579995 176.3375015258789 344.57498550415033 176.3375015258789 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1201)"></path></g></svg> 点对点技术`(peer-to-peer P2P)`又称对等互联网络技术,是一种网络新技术,依赖网络中参与者的计算能力和带宽,而不是把依赖都聚集在较少的几台服务器上(这种技术可以大大减轻服务器的负担)。`P2P`网络通常用于通过`Ad Hoc`连接来连接节点(从而实现了节点之间的通讯),客户端二点之间直接通信,它是没有速度限制的,速度由二点之间的网络传输速度决定 #### 穿透原理 **主机`1`和主机`2 `进行`P2P`通讯的步骤** - **1**.主机1和主机2首次发送数据到服务器(当发送第一次数据的时候,`NAT`上就会自动打了一个“洞”,服务器此时就把它们的外网`IP`和经过`NAT`端口转换的端口存储起来) - **2**.数秒发送一次数据到服务器,就当作是心跳包(因为`UDP`协议的内网打洞在`NAT`上的端口有生命期,一段时间没有数据通过`NAT`上的“洞”这个“洞”就会自动关闭) - **3**.当主机1要访问主机2的时候,主机1先向服务器发送信息要求获取主机2的外网IP和经过`NAT2`端口转换的端口 - **4**.因为在第2步的时候,`NAT1`和`NAT2`已经打好洞了,所以此时就不用再考虑其他,直接向主机`2`的外网`IP`加经过`NAT2`端口转换的端口发送数据就行了(格式是“主机2外网IP”+“:”+“NAT2转换的端口”),如无防火墙的拦截,主机2就可以收到主机1发送的数据了。 #### 功能场景 > - 客户端之间建立直接通讯,不走服务器中转,服务器只是索引 > - 大流量传输环境 ## 内网共享 <svg id="SvgjsSvg1125" preserveAspectRatio="xMinYMin meet" viewBox="0,0,400,400" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" width="100%" height="362.0625"><defs id="SvgjsDefs1126"><pattern id="SvgjsPattern1129" x="0" y="0" width="59.50001525878906" height="58.999977111816406" patternUnits="userSpaceOnUse"><image id="SvgjsImage1130" xlink:href="https://img8.file.cache.docer.com/storage/image/9/3/4/4/5/031b903037dad22548d1c23c461c2250.png/128x128.png" width="59.50001525878906" height="58.999977111816406" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1133" x="0" y="0" width="55.787488619163696" height="56.146755986929094" patternUnits="userSpaceOnUse"><image id="SvgjsImage1134" xlink:href="https://img8.file.cache.docer.com/storage/image/5/f/0/5/7/7e395dcdf10dd2dd0b75588e5f6dc67d.png/128x128.png" width="55.787488619163696" height="56.146755986929094" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><marker id="SvgjsMarker1159" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1160" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1167" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1168" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><pattern id="SvgjsPattern1175" x="0" y="0" width="48" height="49" patternUnits="userSpaceOnUse"><image id="SvgjsImage1176" xlink:href="https://img7.file.cache.docer.com/storage/image/0/d/2/3/c/981b0cd3dc23ee022274a41f37ae6bc2.png/128x128.png" width="48" height="49" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1179" x="0" y="0" width="42" height="43.85319823670375" patternUnits="userSpaceOnUse"><image id="SvgjsImage1180" xlink:href="https://img7.file.cache.docer.com/storage/image/0/2/9/6/7/a14d08192e3022c29bc01485628c6076.png/128x128.png" width="42" height="43.85319823670375" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1183" x="0" y="0" width="64" height="64" patternUnits="userSpaceOnUse"><image id="SvgjsImage1184" xlink:href="https://img7.file.cache.docer.com/storage/image/7/f/3/2/0/87887c77f1eca36734f222702083ef0a.png/128x128.png" width="64" height="64" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><marker id="SvgjsMarker1187" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1188" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1195" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1196" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1199" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1200" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1207" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1208" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1215" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1216" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1223" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1224" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1231" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1232" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1243" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1244" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker></defs><g id="SvgjsG1127" transform="translate(311.0749816894531,112.4999885559082)"><path id="SvgjsPath1128" d="M0 0L59.50001525878906 0L59.50001525878906 58.999977111816406L0 58.999977111816406Z " stroke="none" fill="url(#SvgjsPattern1129)"></path></g><g id="SvgjsG1131" transform="translate(68.78750832907849,109)"><path id="SvgjsPath1132" d="M0 0L55.787488619163696 0L55.787488619163696 56.146755986929094L0 56.146755986929094Z " stroke="none" fill="url(#SvgjsPattern1133)"></path></g><g id="SvgjsG1135" transform="translate(293.5749969482422,67.5000114440918)"><path id="SvgjsPath1136" d="M0 4Q0 0 4 0L105 0Q109 0 109 4L109 37.4999885559082Q109 41.4999885559082 105 41.4999885559082L4 41.4999885559082Q0 41.4999885559082 0 37.4999885559082Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1137"><text id="SvgjsText1138" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="87" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="1.1499942779541015" transform="rotate(0)"><tspan id="SvgjsTspan1139" dy="17" x="55"><tspan id="SvgjsTspan1140" style="text-decoration:;">DHCP服务器 </tspan></tspan><tspan id="SvgjsTspan1141" dy="17" x="55"><tspan id="SvgjsTspan1142" style="text-decoration:;"> 推送路由</tspan></tspan></text></g></g><g id="SvgjsG1143" transform="translate(226.07498168945312,25)"><path id="SvgjsPath1144" d="M0 0L90 0L106 16L106 29L0 29L0 0Z " stroke="none" fill-opacity="1" fill="#ffffaa"></path><path id="SvgjsPath1145" d="M90 0L90 16L106 16Z " stroke="none" fill-opacity="1" fill="#cdcdcd"></path><path id="SvgjsPath1146" d="M0 0L90 0L106 16L106 29L0 29L0 0Z " stroke="none" fill="none"></path><g id="SvgjsG1147"><text id="SvgjsText1148" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="65" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="4.55" transform="rotate(0)"><tspan id="SvgjsTspan1149" dy="16" x="53.5"><tspan id="SvgjsTspan1150" style="text-decoration:;">公网服务器</tspan></tspan></text></g></g><g id="SvgjsG1151" transform="translate(49.01686072998018,171.4999656677246)"><path id="SvgjsPath1152" d="M0 4Q0 0 4 0L86.11624191894578 0Q90.11624191894578 0 90.11624191894578 4L90.11624191894578 16.148351694610028Q90.11624191894578 20.148351694610028 86.11624191894578 20.148351694610028L4 20.148351694610028Q0 20.148351694610028 0 16.148351694610028Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1153"><text id="SvgjsText1154" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="70" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.025824152694986" transform="rotate(0)"><tspan id="SvgjsTspan1155" dy="17" x="46"><tspan id="SvgjsTspan1156" style="text-decoration:;">网关服务器</tspan></tspan></text></g></g><g id="SvgjsG1157"><path id="SvgjsPath1158" d="M311.0749816894531 141.9999771118164C224.3075504303129 141.9999771118164 162.5749969482422 55 96.68125263866034 109 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1159)"></path><rect id="SvgjsRect1161" width="52" height="16" x="170.0504845579723" y="97.2499885559082" fill="#ffffff"></rect><text id="SvgjsText1162" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="52" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="95.2999885559082" transform="rotate(0)"><tspan id="SvgjsTspan1163" dy="16" x="196.0504845579723"><tspan id="SvgjsTspan1164" style="text-decoration:;">转发流量</tspan></tspan></text></g><g id="SvgjsG1165"><path id="SvgjsPath1166" d="M124.57499694824219 137.07337799346453C212.1642649110975 137.07337799346453 230.5749969482422 184 340.82498931884766 171.4999656677246 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1167)"></path><rect id="SvgjsRect1169" width="55" height="16" x="196.70222148063863" y="150.97418470519784" fill="#ffffff"></rect><text id="SvgjsText1170" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="54" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="149.02418470519785" transform="rotate(0)"><tspan id="SvgjsTspan1171" dy="16" x="224.20222148063863"><tspan id="SvgjsTspan1172" style="text-decoration:;">NAT转换</tspan></tspan></text></g><g id="SvgjsG1173" transform="translate(279.5749969482422,266)"><path id="SvgjsPath1174" d="M0 0L48 0L48 49L0 49Z " stroke="none" fill="url(#SvgjsPattern1175)"></path></g><g id="SvgjsG1177" transform="translate(382.0749816894531,266)"><path id="SvgjsPath1178" d="M0 0L42 0L42 43.85319823670375L0 43.85319823670375Z " stroke="none" fill="url(#SvgjsPattern1179)"></path></g><g id="SvgjsG1181" transform="translate(166.5749969482422,255.92659911835187)"><path id="SvgjsPath1182" d="M0 0L64 0L64 64L0 64Z " stroke="none" fill="url(#SvgjsPattern1183)"></path></g><g id="SvgjsG1185"><path id="SvgjsPath1186" d="M198.5749969482422 255.92659911835187C198.5749969482422 189.75963846245486 249.5749969482422 236 340.82498931884766 171.4999656677246 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1187)"></path><rect id="SvgjsRect1189" width="26" height="16" x="222.48124599456787" y="205.08818502168015" fill="#ffffff"></rect><text id="SvgjsText1190" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="26" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="203.13818502168016" transform="rotate(0)"><tspan id="SvgjsTspan1191" dy="16" x="235.48124599456787"><tspan id="SvgjsTspan1192" style="text-decoration:;">请求</tspan></tspan></text></g><g id="SvgjsG1193"><path id="SvgjsPath1194" d="M303.5749969482422 266C303.5749969482422 225.3693348901864 340.82498931884766 212.13063077753822 340.82498931884766 171.4999656677246 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1195)"></path></g><g id="SvgjsG1197"><path id="SvgjsPath1198" d="M403.0749816894531 266C403.0749816894531 220.73576592683065 340.82498931884766 216.76419974089396 340.82498931884766 171.4999656677246 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1199)"></path><rect id="SvgjsRect1201" width="26" height="16" x="358.9499855041504" y="210.7499828338623" fill="#ffffff"></rect><text id="SvgjsText1202" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="26" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="208.79998283386232" transform="rotate(0)"><tspan id="SvgjsTspan1203" dy="16" x="371.9499855041504"><tspan id="SvgjsTspan1204" style="text-decoration:;">请求</tspan></tspan></text></g><g id="SvgjsG1205"><path id="SvgjsPath1206" d="M370.5749969482422 141.9999771118164C432.74486408987036 141.9999771118164 486.2448488310813 287.9265991183519 424.0749816894531 287.9265991183519 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1207)"></path><rect id="SvgjsRect1209" width="52" height="16" x="417.9523896750688" y="206.96328811508414" fill="#ffffff"></rect><text id="SvgjsText1210" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="52" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="205.01328811508415" transform="rotate(0)"><tspan id="SvgjsTspan1211" dy="16" x="443.9523896750688"><tspan id="SvgjsTspan1212" style="text-decoration:;">转发流量</tspan></tspan></text></g><g id="SvgjsG1213"><path id="SvgjsPath1214" d="M340.82498931884766 171.4999656677246C340.82498931884766 219.3941331103748 375.4691643908924 290.5 327.5749969482422 290.5 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1215)"></path><rect id="SvgjsRect1217" width="52" height="16" x="326.16030592453876" y="240.96029562485614" fill="#ffffff"></rect><text id="SvgjsText1218" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="52" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="239.01029562485616" transform="rotate(0)"><tspan id="SvgjsTspan1219" dy="16" x="352.16030592453876"><tspan id="SvgjsTspan1220" style="text-decoration:;">转发流量</tspan></tspan></text></g><g id="SvgjsG1221"><path id="SvgjsPath1222" d="M340.82498931884766 171.4999656677246C302.5749969482422 235 254.5749969482422 285 230.5749969482422 287.9265991183519 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1223)"></path><rect id="SvgjsRect1225" width="52" height="16" x="254.35624599456787" y="244.42832059825957" fill="#ffffff"></rect><text id="SvgjsText1226" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="52" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="242.4783205982596" transform="rotate(0)"><tspan id="SvgjsTspan1227" dy="16" x="280.35624599456787"><tspan id="SvgjsTspan1228" style="text-decoration:;">转发流量</tspan></tspan></text></g><g id="SvgjsG1229"><path id="SvgjsPath1230" d="M279.0749816894531 54C279.0749816894531 91.45503111023717 273.619950579216 141.9999771118164 311.0749816894531 141.9999771118164 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1231)"></path></g><g id="SvgjsG1233" transform="translate(64.07498168945312,25)"><path id="SvgjsPath1234" d="M0 0L90 0L106 16L106 29L0 29L0 0Z " stroke="none" fill-opacity="1" fill="#ffffaa"></path><path id="SvgjsPath1235" d="M90 0L90 16L106 16Z " stroke="none" fill-opacity="1" fill="#cdcdcd"></path><path id="SvgjsPath1236" d="M0 0L90 0L106 16L106 29L0 29L0 0Z " stroke="none" fill="none"></path><g id="SvgjsG1237"><text id="SvgjsText1238" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="52" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="4.55" transform="rotate(0)"><tspan id="SvgjsTspan1239" dy="16" x="53.5"><tspan id="SvgjsTspan1240" style="text-decoration:;">内网设备</tspan></tspan></text></g></g><g id="SvgjsG1241"><path id="SvgjsPath1242" d="M64.07498168945312 39.5C25.000136583406317 39.5 29.712663223031683 137.07337799346453 68.78750832907849 137.07337799346453 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1243)"></path></g><g id="SvgjsG1245" transform="translate(175.29592883911118,317.0741529591214)"><path id="SvgjsPath1246" d="M0 4Q0 0 4 0L42.55813621826201 0Q46.55813621826201 0 46.55813621826201 4L46.55813621826201 16Q46.55813621826201 20 42.55813621826201 20L4 20Q0 20 0 16Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1247"><text id="SvgjsText1248" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="18" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.1" transform="rotate(0)"><tspan id="SvgjsTspan1249" dy="17" x="24"><tspan id="SvgjsTspan1250" style="text-decoration:;">PC</tspan></tspan></text></g></g><g id="SvgjsG1251" transform="translate(275.7959288391112,317.0741529591214)"><path id="SvgjsPath1252" d="M0 4Q0 0 4 0L51.55813621826201 0Q55.55813621826201 0 55.55813621826201 4L55.55813621826201 16Q55.55813621826201 20 51.55813621826201 20L4 20Q0 20 0 16Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1253"><text id="SvgjsText1254" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="28" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.1" transform="rotate(0)"><tspan id="SvgjsTspan1255" dy="17" x="28.5"><tspan id="SvgjsTspan1256" style="text-decoration:;">移动</tspan></tspan></text></g></g><g id="SvgjsG1257" transform="translate(375.2959135803221,317.0741529591214)"><path id="SvgjsPath1258" d="M0 4Q0 0 4 0L51.55813621826201 0Q55.55813621826201 0 55.55813621826201 4L55.55813621826201 16Q55.55813621826201 20 51.55813621826201 20L4 20Q0 20 0 16Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1259"><text id="SvgjsText1260" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="36" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.1" transform="rotate(0)"><tspan id="SvgjsTspan1261" dy="17" x="28.5"><tspan id="SvgjsTspan1262" style="text-decoration:;">IPAD</tspan></tspan></text></g></g></svg> 内网共享,介于远程组网和内网穿透之间,本质上来讲,也是把内网的环境穿透出来共享到外部网络,只不过穿透的方式类似于远程组网,属于`VPN`的范围了. 简单来说,你有一台在内网的机器,你可以使用技术手段或者软件来远程访问到他,比如传输文件,远程桌面什么的,但是你不能应用他的网络去访问他所处的内网资源,这个只是叫远程局域网。那么内网共享的概念就是把这台内网设备的本地网络共享出来让外网的设备应用,具体的实施方案可参考之前写的这篇文章。 整体结构就是把公网服务器用于`DHCP`服务器为接入的设备分配`IP`地址和推送路由,内网客户端用于网关`NAT`,对服务器传过来请求进行进行转换,虚拟一个路由器的环境出来,实现远程接入的设备提供内网客户端同样的网络环境。 <div class="preview"> <div class="post-inser post box-shadow-wrap-normal"> <a href="https://www.itggg.cn/xuexi/203.html" target="_blank" class="post_inser_a no-external-link no-underline-link"> <div class="inner-image bg" style="background-image: url(https://img-1259793745.itggg.cn/20201222195307.jpg);background-size: cover;"></div> <div class="inner-content" > <p class="inser-title">搭建内网共享服务器</p> <div class="inster-summary text-muted"> Intranet penetrationDHCP服务器 推送路由公网服务器网关服务器转发流量NAT转换请求请求... </div> </div> </a> <!-- .inner-content #####--> </div> <!-- .post-inser ####--> </div> #### 功能场景 > - **远程局域网** > - **把处于内网环境中的设备本地的网络环境共享到外部** > - **远程访问内网资源** ## 工具对比和选择 <div class="tip inlineBlock info"> **从是否有API,客户端单独key,本地化,收费模式,开发语言,github stars多个维度比较了几款内网穿透工具** </div> | 地址 | 名称 | API | 单独key | 本地化 | 收费 | 开发语言 | github | | ------------------------------------------------ | -------- | ------ | ------- | ------ | ------- | -------- | ------ | | [官网](https://github.com/inconshreveable/ngrok) | ngrok | 支持 | 未知 | 支持 | 按数量 | go | 16K | | [官网](https://github.com/fatedier/frp) | frp | 不支持 | 统一 | 支持 | 免费 | go | 26K | | [官网](https://github.com/ffay/lanproxy) | lanproxy | 不支持 | 单独 | 未知 | 免费 | java | 3K | | [官网](https://github.com/snail007/goproxy) | goproxy | 支持 | 未知 | 未知 | API收费 | go | 6K | | [官网](https://github.com/cnlh/nps) | nps | 支持 | 单独 | 支持 | 免费 | go | 6K | | [官网](https://www.kingdriod.cn/) | 神卓互联 | 未知 | 未知 | 不支持 | 收费 | 未知 | 未知 | | [官网](https://hsk.oray.com/) | 花生壳 | 未知 | 未知 | 不支持 | 收费 | 未知 | 未知 | | [官网](https://natapp.cn/) | Natapp | 未知 | 未知 | 不支持 | 收费 | 未知 | 未知 | ## 我的方案 <svg id="SvgjsSvg1227" preserveAspectRatio="xMinYMin meet" viewBox="0,0,600,300" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" width="100%" height="535.2125091552734"><defs id="SvgjsDefs1228"><pattern id="SvgjsPattern1231" x="0" y="0" width="64" height="64" patternUnits="userSpaceOnUse"><image id="SvgjsImage1232" xlink:href="https://img8.file.cache.docer.com/storage/image/9/3/4/4/5/031b903037dad22548d1c23c461c2250.png/128x128.png" width="64" height="64" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1235" x="0" y="0" width="64" height="64" patternUnits="userSpaceOnUse"><image id="SvgjsImage1236" xlink:href="https://img8.file.cache.docer.com/storage/image/e/2/8/2/7/bb5cec7a27d4f5108fab09b423188673.png/128x128.png" width="64" height="64" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><marker id="SvgjsMarker1239" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1240" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><pattern id="SvgjsPattern1247" x="0" y="0" width="64" height="64" patternUnits="userSpaceOnUse"><image id="SvgjsImage1248" xlink:href="https://img7.file.cache.docer.com/storage/image/0/4/9/d/3/7a27021b4517e4d69c80dcebd3def837.png/128x128.png" width="64" height="64" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1251" x="0" y="0" width="64" height="64" patternUnits="userSpaceOnUse"><image id="SvgjsImage1252" xlink:href="https://img7.file.cache.docer.com/storage/image/0/4/9/d/3/7a27021b4517e4d69c80dcebd3def837.png/128x128.png" width="64" height="64" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1255" x="0" y="0" width="64" height="64" patternUnits="userSpaceOnUse"><image id="SvgjsImage1256" xlink:href="https://img7.file.cache.docer.com/storage/image/0/4/9/d/3/7a27021b4517e4d69c80dcebd3def837.png/128x128.png" width="64" height="64" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1259" x="0" y="0" width="64" height="64" patternUnits="userSpaceOnUse"><image id="SvgjsImage1260" xlink:href="https://img7.file.cache.docer.com/storage/image/0/4/9/d/3/7a27021b4517e4d69c80dcebd3def837.png/128x128.png" width="64" height="64" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><pattern id="SvgjsPattern1263" x="0" y="0" width="64" height="64" patternUnits="userSpaceOnUse"><image id="SvgjsImage1264" xlink:href="https://img7.file.cache.docer.com/storage/image/0/4/9/d/3/7a27021b4517e4d69c80dcebd3def837.png/128x128.png" width="64" height="64" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><marker id="SvgjsMarker1267" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1268" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1271" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1272" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1279" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1280" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1283" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1284" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1291" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1292" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1295" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1296" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1303" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1304" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1311" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1312" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1315" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1316" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1319" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1320" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><pattern id="SvgjsPattern1323" x="0" y="0" width="64" height="64" patternUnits="userSpaceOnUse"><image id="SvgjsImage1324" xlink:href="https://img7.file.cache.docer.com/storage/image/1/a/7/5/d/19e71e0caa41d04e70faec9d564bf5d3.png/128x128.png" width="64" height="64" preserveAspectRatio="none" crossOrigin="anonymous" x="0" y="0"></image></pattern><marker id="SvgjsMarker1327" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1328" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1383" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1384" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1391" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1392" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1415" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1416" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1427" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1428" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1431" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1432" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1435" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1436" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1439" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1440" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1443" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1444" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker><marker id="SvgjsMarker1447" markerWidth="16" markerHeight="12" refX="16" refY="6" viewBox="0 0 16 12" orient="auto" markerUnits="userSpaceOnUse"><path id="SvgjsPath1448" d="M0 2L14 6L0 11L0 2 " fill="#323232" stroke="#323232" stroke-width="2"></path></marker></defs><g id="SvgjsG1229" transform="translate(252.62498474121094,203.07498168945312)"><path id="SvgjsPath1230" d="M0 0L64 0L64 64L0 64Z " stroke="none" fill="url(#SvgjsPattern1231)"></path></g><g id="SvgjsG1233" transform="translate(350.125,47.07500457763672)"><path id="SvgjsPath1234" d="M0 0L64 0L64 64L0 64Z " stroke="none" fill="url(#SvgjsPattern1235)"></path></g><g id="SvgjsG1237"><path id="SvgjsPath1238" d="M284.62498474121094 203.07498168945312C284.62498474121094 149.45371909478632 382.125 164.69626717230352 382.125 111.07500457763672 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1239)"></path><rect id="SvgjsRect1241" width="52" height="16" x="307.37499237060547" y="149.07499313354492" fill="#ffffff"></rect><text id="SvgjsText1242" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="52" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="147.12499313354493" transform="rotate(0)"><tspan id="SvgjsTspan1243" dy="16" x="333.37499237060547"><tspan id="SvgjsTspan1244" style="text-decoration:;">代理请求</tspan></tspan></text></g><g id="SvgjsG1245" transform="translate(44.125,348.0749816894531)"><path id="SvgjsPath1246" d="M0 0L64 0L64 64L0 64Z " stroke="none" fill="url(#SvgjsPattern1247)"></path></g><g id="SvgjsG1249" transform="translate(252.62498474121094,348.0749816894531)"><path id="SvgjsPath1250" d="M0 0L64 0L64 64L0 64Z " stroke="none" fill="url(#SvgjsPattern1251)"></path></g><g id="SvgjsG1253" transform="translate(148.62498474121094,348.0749816894531)"><path id="SvgjsPath1254" d="M0 0L64 0L64 64L0 64Z " stroke="none" fill="url(#SvgjsPattern1255)"></path></g><g id="SvgjsG1257" transform="translate(367.125,348.0749816894531)"><path id="SvgjsPath1258" d="M0 0L64 0L64 64L0 64Z " stroke="none" fill="url(#SvgjsPattern1259)"></path></g><g id="SvgjsG1261" transform="translate(465.62498474121094,348.0749816894531)"><path id="SvgjsPath1262" d="M0 0L64 0L64 64L0 64Z " stroke="none" fill="url(#SvgjsPattern1263)"></path></g><g id="SvgjsG1265"><path id="SvgjsPath1266" d="M76.125 348.0749816894531C76.125 258.60253351721616 225.125 301.0750045776367 284.62498474121094 267.0749816894531 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1267)"></path></g><g id="SvgjsG1269"><path id="SvgjsPath1270" d="M180.62498474121094 348.0749816894531C180.62498474121094 295.34624189795045 284.62498474121094 319.8037214809558 284.62498474121094 267.0749816894531 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1271)"></path><rect id="SvgjsRect1273" width="62" height="16" x="201.62498474121094" y="299.5749816894531" fill="#ffffff"></rect><text id="SvgjsText1274" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="61" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="297.62498168945314" transform="rotate(0)"><tspan id="SvgjsTspan1275" dy="16" x="232.62498474121094"><tspan id="SvgjsTspan1276" style="text-decoration:;">HTTP响应</tspan></tspan></text></g><g id="SvgjsG1277"><path id="SvgjsPath1278" d="M284.62498474121094 348.0749816894531L284.62498474121094 307.5749816894531L284.62498474121094 307.5749816894531L284.62498474121094 267.0749816894531 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1279)"></path></g><g id="SvgjsG1281"><path id="SvgjsPath1282" d="M399.125 348.0749816894531C399.125 291.9732833276204 284.62498474121094 323.17668005128587 284.62498474121094 267.0749816894531 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1283)"></path><rect id="SvgjsRect1285" width="62" height="16" x="310.87499237060547" y="299.5749816894531" fill="#ffffff"></rect><text id="SvgjsText1286" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="61" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="297.62498168945314" transform="rotate(0)"><tspan id="SvgjsTspan1287" dy="16" x="341.87499237060547"><tspan id="SvgjsTspan1288" style="text-decoration:;">HTTP响应</tspan></tspan></text></g><g id="SvgjsG1289"><path id="SvgjsPath1290" d="M497.62498474121094 348.0749816894531C433.125 271.0750045776367 347.125 291.0750045776367 284.62498474121094 267.0749816894531 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1291)"></path></g><g id="SvgjsG1293"><path id="SvgjsPath1294" d="M252.62498474121094 235.07498168945312C168.79540083323946 235.07498168945312 76.125 264.24539778148164 76.125 348.0749816894531 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1295)"></path><rect id="SvgjsRect1297" width="62" height="16" x="101.93889840511616" y="252.13888772396382" fill="#ffffff"></rect><text id="SvgjsText1298" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="61" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="250.18888772396383" transform="rotate(0)"><tspan id="SvgjsTspan1299" dy="16" x="132.93889840511616"><tspan id="SvgjsTspan1300" style="text-decoration:;">HTTP请求</tspan></tspan></text></g><g id="SvgjsG1301"><path id="SvgjsPath1302" d="M316.62498474121094 235.07498168945312C401.97602457084633 235.07498168945312 497.62498474121094 262.7239418598178 497.62498474121094 348.0749816894531 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1303)"></path><rect id="SvgjsRect1305" width="62" height="16" x="408.1316246773242" y="251.56834175333984" fill="#ffffff"></rect><text id="SvgjsText1306" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="61" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="249.61834175333985" transform="rotate(0)"><tspan id="SvgjsTspan1307" dy="16" x="439.1316246773242"><tspan id="SvgjsTspan1308" style="text-decoration:;">HTTP请求</tspan></tspan></text></g><g id="SvgjsG1309"><path id="SvgjsPath1310" d="M252.62498474121094 235.07498168945312C199.02946254019116 235.07498168945312 180.62498474121094 294.47945948843335 180.62498474121094 348.0749816894531 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1311)"></path></g><g id="SvgjsG1313"><path id="SvgjsPath1314" d="M284.62498474121094 267.0749816894531L284.62498474121094 307.5749816894531L284.62498474121094 307.5749816894531L284.62498474121094 348.0749816894531 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1315)"></path></g><g id="SvgjsG1317"><path id="SvgjsPath1318" d="M316.62498474121094 235.07498168945312C372.58962002843555 235.07498168945312 399.125 292.1103464022285 399.125 348.0749816894531 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1319)"></path></g><g id="SvgjsG1321" transform="translate(59.125,47.07500457763672)"><path id="SvgjsPath1322" d="M0 0L64 0L64 64L0 64Z " stroke="none" fill="url(#SvgjsPattern1323)"></path></g><g id="SvgjsG1325"><path id="SvgjsPath1326" d="M123.125 79.07500457763672C214.125 54.07500648498535 258.125 64.07500648498535 350.125 79.07500457763672 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1327)"></path><rect id="SvgjsRect1329" width="26" height="16" x="223.25" y="56.07500600814819" fill="#ffffff"></rect><text id="SvgjsText1330" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="26" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="54.12500600814819" transform="rotate(0)"><tspan id="SvgjsTspan1331" dy="16" x="236.25"><tspan id="SvgjsTspan1332" style="text-decoration:;">请求</tspan></tspan></text></g><g id="SvgjsG1333" transform="translate(25.008758081054225,420.0750045776367)"><path id="SvgjsPath1334" d="M0 4Q0 0 4 0L86.11624191894578 0Q90.11624191894578 0 90.11624191894578 4L90.11624191894578 16.148351694610028Q90.11624191894578 20.148351694610028 86.11624191894578 20.148351694610028L4 20.148351694610028Q0 20.148351694610028 0 16.148351694610028Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1335"><text id="SvgjsText1336" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="70" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.025824152694986" transform="rotate(0)"><tspan id="SvgjsTspan1337" dy="17" x="46"><tspan id="SvgjsTspan1338" style="text-decoration:;">应用服务器</tspan></tspan></text></g></g><g id="SvgjsG1339" transform="translate(135.56686378173805,420.0750045776367)"><path id="SvgjsPath1340" d="M0 4Q0 0 4 0L86.11624191894578 0Q90.11624191894578 0 90.11624191894578 4L90.11624191894578 16.148351694610028Q90.11624191894578 20.148351694610028 86.11624191894578 20.148351694610028L4 20.148351694610028Q0 20.148351694610028 0 16.148351694610028Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1341"><text id="SvgjsText1342" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="70" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.025824152694986" transform="rotate(0)"><tspan id="SvgjsTspan1343" dy="17" x="46"><tspan id="SvgjsTspan1344" style="text-decoration:;">应用服务器</tspan></tspan></text></g></g><g id="SvgjsG1345" transform="translate(239.56686378173805,420.0750045776367)"><path id="SvgjsPath1346" d="M0 4Q0 0 4 0L86.11624191894578 0Q90.11624191894578 0 90.11624191894578 4L90.11624191894578 16.148351694610028Q90.11624191894578 20.148351694610028 86.11624191894578 20.148351694610028L4 20.148351694610028Q0 20.148351694610028 0 16.148351694610028Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1347"><text id="SvgjsText1348" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="70" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.025824152694986" transform="rotate(0)"><tspan id="SvgjsTspan1349" dy="17" x="46"><tspan id="SvgjsTspan1350" style="text-decoration:;">应用服务器</tspan></tspan></text></g></g><g id="SvgjsG1351" transform="translate(354.06687904052706,420.0750045776367)"><path id="SvgjsPath1352" d="M0 4Q0 0 4 0L86.11624191894578 0Q90.11624191894578 0 90.11624191894578 4L90.11624191894578 16.148351694610028Q90.11624191894578 20.148351694610028 86.11624191894578 20.148351694610028L4 20.148351694610028Q0 20.148351694610028 0 16.148351694610028Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1353"><text id="SvgjsText1354" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="70" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.025824152694986" transform="rotate(0)"><tspan id="SvgjsTspan1355" dy="17" x="46"><tspan id="SvgjsTspan1356" style="text-decoration:;">应用服务器</tspan></tspan></text></g></g><g id="SvgjsG1357" transform="translate(459.566863781738,420.0750045776367)"><path id="SvgjsPath1358" d="M0 4Q0 0 4 0L86.11624191894578 0Q90.11624191894578 0 90.11624191894578 4L90.11624191894578 16.148351694610028Q90.11624191894578 20.148351694610028 86.11624191894578 20.148351694610028L4 20.148351694610028Q0 20.148351694610028 0 16.148351694610028Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1359"><text id="SvgjsText1360" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="70" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.025824152694986" transform="rotate(0)"><tspan id="SvgjsTspan1361" dy="17" x="46"><tspan id="SvgjsTspan1362" style="text-decoration:;">应用服务器</tspan></tspan></text></g></g><g id="SvgjsG1363" transform="translate(123.125,203.07498168945312)"><path id="SvgjsPath1364" d="M0 4Q0 0 4 0L125.49998474121094 0Q129.49998474121094 0 129.49998474121094 4L129.49998474121094 20.074175847305014Q129.49998474121094 24.074175847305014 125.49998474121094 24.074175847305014L4 24.074175847305014Q0 24.074175847305014 0 20.074175847305014Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1365"><text id="SvgjsText1366" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="105" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="0.9370879236525069" transform="rotate(0)"><tspan id="SvgjsTspan1367" dy="17" x="65.5"><tspan id="SvgjsTspan1368" style="text-decoration:;">NGINX反向代理</tspan></tspan></text></g></g><g id="SvgjsG1369" transform="translate(45.450621862792275,29.00080584214811)"><path id="SvgjsPath1370" d="M0 4Q0 0 4 0L86.11624191894578 0Q90.11624191894578 0 90.11624191894578 4L90.11624191894578 16.148351694610028Q90.11624191894578 20.148351694610028 86.11624191894578 20.148351694610028L4 20.148351694610028Q0 20.148351694610028 0 16.148351694610028Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1371"><text id="SvgjsText1372" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="42" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.025824152694986" transform="rotate(0)"><tspan id="SvgjsTspan1373" dy="17" x="46"><tspan id="SvgjsTspan1374" style="text-decoration:;">浏览器</tspan></tspan></text></g></g><g id="SvgjsG1375" transform="translate(316.62498474121094,25.00080584214811)"><path id="SvgjsPath1376" d="M0 4Q0 0 4 0L118.558136218262 0Q122.558136218262 0 122.558136218262 4L122.558136218262 16Q122.558136218262 20 118.558136218262 20L4 20Q0 20 0 16Z " stroke="rgba(255,153,204,1)" stroke-width="2" fill-opacity="1" fill="#ff9999"></path><g id="SvgjsG1377"><text id="SvgjsText1378" font-family="微软雅黑" text-anchor="middle" font-size="14px" width="94" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="-1.1" transform="rotate(0)"><tspan id="SvgjsTspan1379" dy="17" x="62"><tspan id="SvgjsTspan1380" style="text-decoration:;">HTTP正向代理</tspan></tspan></text></g></g><g id="SvgjsG1381"><path id="SvgjsPath1382" d="M414.125 79.07500457763672C444.125 111.07500648498535 360.125 192.07500648498535 316.62498474121094 235.07498168945312 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1383)"></path><rect id="SvgjsRect1385" width="52" height="16" x="366.93749809265137" y="144.95000314712524" fill="#ffffff"></rect><text id="SvgjsText1386" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="52" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="143.00000314712526" transform="rotate(0)"><tspan id="SvgjsTspan1387" dy="16" x="392.93749809265137"><tspan id="SvgjsTspan1388" style="text-decoration:;">响应请求</tspan></tspan></text></g><g id="SvgjsG1389"><path id="SvgjsPath1390" d="M350.125 79.07500457763672C259.125 114.07500648498535 211.125 115.07500648498535 123.125 79.07500457763672 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1391)"></path><rect id="SvgjsRect1393" width="26" height="16" x="222.5" y="97.7000060081482" fill="#ffffff"></rect><text id="SvgjsText1394" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="26" fill="#323232" font-weight="700" align="top" font-style="" opacity="1" y="95.75000600814819" transform="rotate(0)"><tspan id="SvgjsTspan1395" dy="16" x="235.5"><tspan id="SvgjsTspan1396" style="text-decoration:;">响应</tspan></tspan></text></g><g id="SvgjsG1397" transform="translate(423.62498474121094,169.07500457763672)"><path id="SvgjsPath1398" d="M0 0L90 0L106 16L106 29L0 29L0 0Z " stroke="none" fill-opacity="1" fill="#ffffaa"></path><path id="SvgjsPath1399" d="M90 0L90 16L106 16Z " stroke="none" fill-opacity="1" fill="#cdcdcd"></path><path id="SvgjsPath1400" d="M0 0L90 0L106 16L106 29L0 29L0 0Z " stroke="none" fill="none"></path><g id="SvgjsG1401"><text id="SvgjsText1402" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="65" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="4.55" transform="rotate(0)"><tspan id="SvgjsTspan1403" dy="16" x="53.5"><tspan id="SvgjsTspan1404" style="text-decoration:;">公网服务器</tspan></tspan></text></g></g><g id="SvgjsG1405" transform="translate(423.62498474121094,200.61206961310563)"><path id="SvgjsPath1406" d="M0 0L90 0L106 16L106 29L0 29L0 0Z " stroke="none" fill-opacity="1" fill="#ffffaa"></path><path id="SvgjsPath1407" d="M90 0L90 16L106 16Z " stroke="none" fill-opacity="1" fill="#cdcdcd"></path><path id="SvgjsPath1408" d="M0 0L90 0L106 16L106 29L0 29L0 0Z " stroke="none" fill="none"></path><g id="SvgjsG1409"><text id="SvgjsText1410" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="78" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="4.55" transform="rotate(0)"><tspan id="SvgjsTspan1411" dy="16" x="53.5"><tspan id="SvgjsTspan1412" style="text-decoration:;">能访问互联网</tspan></tspan></text></g></g><g id="SvgjsG1413"><path id="SvgjsPath1414" d="M423.62498474121094 215.11206961310563C372.125 220.07500648498535 360.16350627526026 235.07498168945312 316.62498474121094 235.07498168945312 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1415)"></path></g><g id="SvgjsG1417" transform="translate(231.62498474121094,501.5749816894531)"><path id="SvgjsPath1418" d="M0 0L90 0L106 16L106 29L0 29L0 0Z " stroke="none" fill-opacity="1" fill="#ffffaa"></path><path id="SvgjsPath1419" d="M90 0L90 16L106 16Z " stroke="none" fill-opacity="1" fill="#cdcdcd"></path><path id="SvgjsPath1420" d="M0 0L90 0L106 16L106 29L0 29L0 0Z " stroke="none" fill="none"></path><g id="SvgjsG1421"><text id="SvgjsText1422" font-family="微软雅黑" text-anchor="middle" font-size="13px" width="65" fill="#323232" font-weight="700" align="middle" font-style="" opacity="1" y="4.55" transform="rotate(0)"><tspan id="SvgjsTspan1423" dy="16" x="53.5"><tspan id="SvgjsTspan1424" style="text-decoration:;">纯内网环境</tspan></tspan></text></g></g><g id="SvgjsG1425"><path id="SvgjsPath1426" d="M70.06687904052711 440.22335627224675C70.06687904052711 529.4862960967441 242.125 458.07500648498535 284.62498474121094 501.5749816894531 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1427)"></path></g><g id="SvgjsG1429"><path id="SvgjsPath1430" d="M180.62498474121094 440.22335627224675C180.62498474121094 488.5224609286822 284.62498474121094 453.27587703301765 284.62498474121094 501.5749816894531 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1431)"></path></g><g id="SvgjsG1433"><path id="SvgjsPath1434" d="M284.62498474121094 440.22335627224675C284.62498474121094 464.7640064391293 284.62498474121094 477.0343315225706 284.62498474121094 501.5749816894531 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1435)"></path></g><g id="SvgjsG1437"><path id="SvgjsPath1438" d="M399.125 440.22335627224675C399.125 492.183764947462 284.62498474121094 449.61457301423786 284.62498474121094 501.5749816894531 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1439)"></path></g><g id="SvgjsG1441"><path id="SvgjsPath1442" d="M504.62498474121094 440.22335627224675C504.62498474121094 531.5811337770291 326.125 459.07500648498535 284.62498474121094 501.5749816894531 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1443)"></path></g><g id="SvgjsG1445"><path id="SvgjsPath1446" d="M476.62498474121094 169.07500457763672L476.62498474121094 79.07500457763672L414.125 79.07500457763672 " stroke="#323232" stroke-width="2" fill="none" marker-end="url(#SvgjsMarker1447)"></path></g></svg> 在对比了一圈后,选用了`NPS`来搞,上面这个拓扑图就是整个方案,整个内网环境的设备只需要有一台服务器能访问互联网就行,并把这台服务器做`nginx`反向代理做其他服务器的出口,然后找一台有公网`IP`的服务器部署`nps`,做`HTTP`正向代理,映射到`nginx`的端口。这样就最低限度的,低维护的可以把整个后端服务公网化。 <div class="tip inlineBlock success"> **安全性** </div> - 这种结构既可以把后端服务器全部公网化,又不直接暴露服务器在互联网上,后端服务器还是处于纯内网的环境,物理隔绝 - 防攻击,服务器全部在后端,就算前面的公网服务器被`DDOS`或`CC`攻击,也影响不到后端,因为`NGINX`这层只是单向连接 - 防渗透,只要项目本身没有什么漏洞,黑客几乎不可能找的到源地址 <div class="tip inlineBlock success"> **适用性** </div> - 低要求,采用这种结构,就算本地机房没有互联网IP也可以,只要随便一台设备能访问互联网就可以 - 接入方便,就算是多个机房,多个地域的内网,也可以全部代理出来 ## NPS部署和使用 [releases](https://github.com/ehang-io/nps/releases) 下载对应的系统版本即可,**服务端和客户端是单独的** <div class="tip inlineBlock warning"> **其他内容请看官方使用手册,写的很详细了,这里就不搬运了** </div> <button class="btn m-b-xs btn-info btn-rounded " onclick='window.open("https://ehang-io.github.io/nps/#/install","_blank")'>使用手册</button> ## 其他应用场景探索 **(实验后补充完善)** - 代理本地项目 - UDP代理 - p2p穿透 - 远程连接 - API Last modification:January 7th, 2021 at 08:22 pm © 禁止转载 Support 如果你想请我喝奶茶的话 ×Close Appreciate the author Sweeping payments Pay by AliPay Pay by WeChat
10 comments
感谢博主分享,你是我见过唯一把这些网络说清楚的人,看了其他好多什么内网穿透,全是你抄我,我抄你的文章,乱七八糟,越看越懵逼。看完你的文章总算把这些概念整明白了, 看君一文章,胜读十年书,哈哈。已赞赏100元,请博主查收!
同楼下一样想问🤔 这个图是什么画的 大佬
没找到类似的画图工具和方法
大佬,你文章的这个拓扑图是怎么画的,不是图片,也不是语法命令,F12看了下,居然是直接用代码生成的,神奇!
这是vditor.js的功能
不是vditor.js的功能,我去vditor.js的官方看了,没有生成这种网络拓扑的方法。
他是类似于typora的拓展功能(使用`mermaid之后里面写东西生成的)
也不是,我找了全网也没有生成这种网络拓扑图的方法,只有等大佬亲自出来教学了。
提供拼多多代发 京东快递 淘宝代发,无需签收,单号网www.kuaidzj.com
谢谢很有用
哈哈,不客气,能帮忙就最好了