Horje
Static IP WSL2 Code Example
Static IP WSL2
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=22 connectaddress=172.19.237.178 connectport=22
Static IP WSL2
#The IP address of a WSL2 machine cannot be made static, however it can be determined using
	wsl hostname -I
#Based on this, Create the following powershell script that will start sshd on the WSL machine
#and route traffic to it.
	wsl.exe sudo /etc/init.d/ssh start
	$wsl_ip = (wsl hostname -I).trim()
	Write-Host "WSL Machine IP: ""$wsl_ip"""
	netsh interface portproxy add v4tov4 listenport=22 connectport=22 connectaddress=$wsl_ip

#Add the following line to the sudoers file via visudo to avoid needing a password to start sshd	
    %sudo ALL=(ALL) NOPASSWD: /etc/init.d/ssh

#From a powershell terminal, Scheduled the script to run at startup
	$trigger = New-JobTrigger -AtStartup -RandomDelay 00:00:15
	Register-ScheduledJob -Trigger $trigger -FilePath C:\route_ssh_to_wsl.ps1 -Name RouteSSHtoWSL




Shell

Related
exit branch git Code Example exit branch git Code Example
freebsd add user Code Example freebsd add user Code Example
comment stopper le serveur apache par defaut ubuntu Code Example comment stopper le serveur apache par defaut ubuntu Code Example
shortcut push github vscode Code Example shortcut push github vscode Code Example
ubuntu set deepin terminal as default Code Example ubuntu set deepin terminal as default Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
13