通过路由器端口映射实现远程桌面连接
寫在前面? 最重要的一點(diǎn)? 如果是光貓撥號(hào) 需要改成路由器撥號(hào)光貓橋接的模式? 然后在端口映射 可能存在 你家的公網(wǎng)ip和光貓的公網(wǎng)ip不一樣 這種情況就是你的光貓連接的是片區(qū)的大路由器 考慮找電信申請(qǐng)一個(gè)公網(wǎng)ip
1.起因
? ? 花生殼,teamviewer 等始終要到服務(wù)器去繞一遍 網(wǎng)絡(luò)不友好,不如干脆直從路由器映射端口來連接;
2.思路
? ? 通過修改本機(jī)遠(yuǎn)程桌面端口,然后在路由器添加端口映射,然后通過定時(shí)任務(wù)將本機(jī)公網(wǎng)IP發(fā)送到郵箱;
從而實(shí)現(xiàn)隨時(shí)獲取遠(yuǎn)程計(jì)算機(jī)公網(wǎng)ip來實(shí)現(xiàn)遠(yuǎn)程桌面連接;
3.行不通的情況
? ? 3.1 沒有公網(wǎng)ip
? ? 3.2 你改不來路由器端口映射
?
4.實(shí)現(xiàn)方法
? ? 4.0 開啟遠(yuǎn)程桌面
? ? 4.1 修改遠(yuǎn)程桌面端口
? ? ? ? 參照:https://jingyan.baidu.com/article/e52e36154ad4f740c60c5136.html
? ? 4.2 修改路由器端口映射
? ? ? ? 此處自行百度你的路由器品牌和型號(hào)去設(shè)置
? ? 4.3? 創(chuàng)建vbs腳本
''getIP 獲取當(dāng)前公網(wǎng)IP并發(fā)送到郵箱 ''路由器端口映射自行處理 大概是nat之類的 ''設(shè)置遠(yuǎn)程桌面端口 https://jingyan.baidu.com/article/e52e36154ad4f740c60c5136.html ''定時(shí)任務(wù)添加方法 https://blog.csdn.net/qianxing111/article/details/80015702 set http=createobject("Microsoft.XMLHTTP") ipp="http://2019.ip138.com/ic.asp" ''ip獲取地址 http.open "get",ipp,false http.send ss=bytes2BSTR(Http.responsebody) intStrA = InStr(1,ss,"[",1)+1 sss=mid(ss,intStrA) intStrB = InStr(1,sss,"]",1)-1 ss=mid(ss,intStrA,intStrB) 'wscript.echo ss Function bytes2BSTR(vIn) strReturn = "" For i = 1 To LenB(vIn) ThisCharCode = AscB(MidB(vIn,i,1)) If ThisCharCode < &H80 Then strReturn = strReturn & Chr(ThisCharCode) Else NextCharCode = AscB(MidB(vIn,i+1,1)) strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode)) i = i + 1 End If Next bytes2BSTR = strReturn End Function Set objFSO = CreateObject("Scripting.FileSystemObject") ''ip緩存文件,當(dāng)ip變化會(huì)更新此文件內(nèi)容并發(fā)送郵件,需要測(cè)試則每次執(zhí)行后刪除此文件 fpath="c:\publicip.dat"Set objFile = objFSO.OpenTextFile(fpath, 1,true) do while objFile.atendofstream<>true fstr = objFile.readline loop objFile.Close If fstr = ss Then wscript.quit Else objFSO.OpenTextFile(fpath, 2).write(ss) End If ''SendEmail NameSpace = "http://schemas.microsoft.com/cdo/configuration/" Set Email = CreateObject("CDO.Message") Email.From = "****@163.com" ''發(fā)件人 Email.To = "****@163.com" ''收件人 Email.Subject = "公網(wǎng)ip通知 -" &date() ''標(biāo)題 Email.Textbody = ss&" ,Date:"&date() 'ss為獲取到的ip With Email.Configuration.Fields .Item(NameSpace&"sendusing") = 2 .Item(NameSpace&"smtpserver") = "smtp.163.com" 'smtp服務(wù)器地址 .Item(NameSpace&"smtpserverport") = 25 .Item(NameSpace&"smtpauthenticate") = 1 .Item(NameSpace&"sendusername") = "***@163.com" ''郵箱賬號(hào) .Item(NameSpace&"sendpassword") = "***" ''郵箱密碼 .Update End With Email.Send? ? ? ? 4.4 將以上代碼復(fù)制 保存為.vbs擴(kuò)展名的文件 然后修改里面的****處 為你自己的信息
? ? ? ? 4.5 創(chuàng)建計(jì)劃任務(wù)
? ? ? ? ? ? 參照:https://blog.csdn.net/qianxing111/article/details/80015702
? ? ? ? ? ? 注:? 在觸發(fā)器那一欄可以加上啟動(dòng)時(shí)
? ? ? ? ? ? 注:? 很重要一點(diǎn) 用戶那個(gè)地方要設(shè)置成system用戶 不然你沒有遠(yuǎn)程連接的時(shí)候 他不會(huì)執(zhí)行?
? ?5. 以上就是我要說的全部內(nèi)容?
總結(jié)
以上是生活随笔為你收集整理的通过路由器端口映射实现远程桌面连接的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql 视图 多个 select_M
- 下一篇: Java+spring基于ssm的基于S