代码拉取完成,页面将自动刷新
/usr/bin/getip
```
ip addr | awk '/^[0-9]+: / {}; /inet.*global.*eth/ {print gensub(/(.*)\/(.*)/, "\\1", "g", $2)}'
```
d:\ip.vbs
d:\Temp
```
wslname = "Ubuntu" 'the name of your wls system, could be checked by command wsl -l
Dim ports
'the ports which need to process ip forward
ports = Array(80,443)
'the file to store wls ip
ipTemp = "D:\Temp\wslip.txt"
If WScript.Arguments.Length = 0 Then
'to get the admin right to run the ip forward commands
CreateObject("Shell.Application").ShellExecute "wscript.exe" _
, """" & WScript.ScriptFullName & """ RunAsAdministrator", , "runas", 1
WScript.Quit
End If
Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
'to get the eth0 ip address of the sub linux system, the script getip is in /usr/bin, and save the ipadress to C:\Temp\wslip.txt
writeip = objShell.Run("cmd /c ""wsl -d " + wslname + " -u root getip"">" + ipTemp,0,True)
'wscript.sleep(1000)'just incase some network problem
'get the ip from ip file
Set f = fso.OpenTextFile(ipTemp, 1)
wslip = f.ReadAll()
f.Close()
'execute the ip forward command for each port number from the list
For i = 0 To UBound(ports)
port = ports(i)
command = "cmd /c ""netsh interface portproxy add v4tov4 listenport=" & port & " listenaddress=0.0.0.0 connectport=" & port & " connectaddress=" + wslip
forwarding = objShell.Run(command,0,True)
Next
```
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。