Mar 30 2022 03:48 AM
Linux servers all have a certain version of Python installed by default, and Python can provide a simple service, it is very easy, You can quickly create a port listener for testing network connectivity
Python2:python -m SimpleHTTPServer 8080
Python3:python -m http.server 8080
May I ask if there is a similar operation on windows server
thx
Mar 30 2022 11:38 AM - edited Mar 30 2022 11:40 AM
@zhifeng_ke You can use the Httplistener module, install-module Httplistener and then run Start-HTTPListener -Port 8080 . Perhaps you will need to allow the port in the Windows Firewall first depending on your environment.
For more information : https://devblogs.microsoft.com/powershell/simple-http-api-for-executing-powershell-scripts/
Mar 31 2022 03:27 AM - edited Mar 31 2022 03:27 AM
Yeah, you can. It's not a command like what you've used in your example but it's perfectly fine for network connectivity testing.
Here's an example using TCP 41000.
Start listening command:
($listener = [System.Net.Sockets.TcpListener]::new([System.Net.IPAddress]::Any, 41000)).Start()
Running a basic test command from on the host itself against the listener from above:
Test-NetConnection -ComputerName localhost -Port 41000
Finally, stop the listener:
$listener.Stop()
Cheers,
Lain
Apr 08 2022 06:04 AM