BeginnerLesson 4 of 16

Networking Tools and Remote Access

ping, tracert, netstat, nslookup, telnet, curl, and WinRM — the essential networking toolkit for diagnosing IIS connectivity failures, port binding conflicts, DNS issues, and firewall blocks from anywhere.

🧒 Simple Explanation (ELI5)

Networking tools are like the diagnostic instruments a plumber uses to check pipes. ping checks if the pipe has water flowing at all. tracert maps every joint in the pipe from your house to the destination. netstat shows you every tap that is currently open in the house. nslookup asks the building directory (DNS) "which apartment is www.example.com in?" telnet knocks specifically on one numbered door. Together they tell you exactly where and why water isn't reaching where it should.

🔧 Why Do We Need It?

🌍 Real-world Analogy

Think of an IIS server as a restaurant kitchen. ping checks if the restaurant is open (lights are on). tracert maps every road from your location to the restaurant. netstat lists every window and door the kitchen currently has open. nslookup asks the city directory for the restaurant's exact address from its name. telnet knocks on the service window and asks "is anyone home on port 80?" If all of these succeed but food still doesn't arrive, the problem is inside the kitchen — and that's when you look at IIS logs.

⚙️ Technical Explanation

ping sends ICMP Echo Request packets and measures round-trip time. It confirms Layer 3 (IP) reachability. Ping blocked by firewall doesn't mean the host is down — IIS servers often have ICMP blocked while port 80/443 are open. Use ping to confirm basic network path, but don't conclude "server is down" from ping failure alone.

tracert (Windows equivalent of Linux traceroute) sends UDP/ICMP packets with incrementing TTL values and records which routers respond with TTL exceeded. Every hop is a router; the first hop is your default gateway, the last is the destination or where the path breaks. Use it to identify network routing problems between a client and an IIS server, particularly across datacenter or cloud network segments.

netstat shows the state of all TCP/UDP connections and listeners. For IIS work: netstat -ano combines addresses+ports with PID. LISTEN state means a port is open and waiting. ESTABLISHED means an active connection is in use. TIME_WAIT is a connection that has closed but is in the TCP 4-minute timeout. Large numbers of TIME_WAIT or CLOSE_WAIT connections indicate application connection pool exhaustion.

nslookup queries DNS servers to resolve hostnames. For IIS: confirm the site hostname resolves to the correct IP, verify that wildcard or SAN certificate hostnames resolve, and diagnose DNS propagation delays when updating server IPs. Use nslookup hostname dns-server-ip to test against a specific DNS server.

WinRM (Windows Remote Management) is the Microsoft implementation of the WS-Management protocol. It enables remote PowerShell sessions (Enter-PSSession), PowerShell remoting (Invoke-Command), and tools like Windows Admin Center. WinRM listens on port 5985 (HTTP) and 5986 (HTTPS). It must be enabled on the target server before remote PowerShell works.

⚠️
netstat vs netsh — Port vs URL Namespace

netstat -ano | findstr :80 shows which process has a TCP socket bound to port 80. But IIS uses HTTP.sys URL namespace reservations — not raw sockets. HTTP.sys is the kernel-driver that owns port 80, and it routes incoming requests to specific IIS sites or other registered applications based on URL prefix registrations. Run netsh http show urlacl to see the URL namespace registrations and netsh http show servicestate to see which IIS sites are actively registered. This is why two different applications (e.g., IIS and WCF self-hosted) can both "use port 80" through HTTP.sys without socket conflict — they register different URL prefixes.

📊 Visual Representation

Network Diagnostic Layers for IIS Connectivity
Layer 7 (Application)
curl http://example.com
Browser test + DevTools
IIS Logs (200/500/403)
Layer 4 (Transport)
telnet server 80
Test-NetConnection -Port 80
netstat -ano
Layer 3 (Network)
ping server
tracert server
route print
DNS Resolution
nslookup hostname
Resolve-DnsName
nslookup hostname dns-ip

⌨️ Commands / Syntax

cmd / PowerShell
# --- ping ---
ping server01.example.com
ping -t 192.168.1.10        # Continuous ping (Ctrl+C to stop)
ping -n 100 192.168.1.10    # Send 100 packets (measure stability)

# --- tracert ---
tracert -d 8.8.8.8          # -d skips reverse DNS lookups (faster)
tracert webserver.corp.local

# --- netstat ---
netstat -ano                          # All connections + ports + PIDs
netstat -ano | findstr :80            # Who is on port 80?
netstat -ano | findstr :443           # Who is on port 443?
netstat -s                            # TCP/UDP/IP statistics summary
netstat -b                            # Show executable owning each connection

# --- nslookup ---
nslookup mysite.example.com           # Resolve using default DNS
nslookup mysite.example.com 8.8.8.8   # Query Google DNS specifically
nslookup -type=A mysite.example.com   # A record only
nslookup -type=MX example.com         # Mail exchange records

# --- PowerShell Equivalents ---
Test-NetConnection -ComputerName web01 -Port 80
Test-NetConnection -ComputerName web01 -Port 443 -InformationLevel Detailed
Resolve-DnsName mysite.example.com
Resolve-DnsName mysite.example.com -Server 8.8.8.8

# --- curl (available in Windows 10/Server 2019+) ---
curl -v http://localhost               # Verbose HTTP request showing headers
curl -k https://localhost              # Skip SSL cert validation
curl -o response.html https://mysite   # Save response body

# --- WinRM / Remote PowerShell ---
winrm quickconfig                               # Enable WinRM on target server
Enter-PSSession -ComputerName webserver01       # Interactive remote session
Invoke-Command -ComputerName webserver01 -ScriptBlock { iisreset }

# --- HTTP.sys URL registrations ---
netsh http show urlacl
netsh http show servicestate
netsh http show sslcert                         # Show SSL certificate bindings

💼 Example (Real-world Use Case)

A user reports that a web application at https://app.company.com is not loading from their office. The L2 engineer's investigation: (1) ping app.company.com — times out, but this server has ICMP blocked; inconclusive. (2) nslookup app.company.com — resolves to 10.0.5.45; DNS is fine. (3) Test-NetConnection -ComputerName 10.0.5.45 -Port 443 — TcpTestSucceeded: False. Port 443 is blocked or not listening. (4) Log into the server, run netstat -ano | findstr :443 — no output. Port 443 is not bound. (5) Open IIS Manager → Site → Bindings — the HTTPS binding was accidentally deleted during a routine configuration change earlier that day. Adding the binding back restores the site immediately. Root cause isolated in 4 commands without touching IIS Manager until the last step.

🧪 Hands-on

  1. Run ping localhost and ping 8.8.8.8. Compare RTT and confirm the local loopback and internet path are functional. Record the average RTT for both.
  2. Run netstat -ano | findstr LISTEN. Identify all listening ports. Find port 80 or 443 if IIS is installed — note the PID. Run tasklist /FI "PID eq <PID>" to confirm it belongs to the System process (HTTP.sys kernel driver).
  3. Run nslookup google.com and compare to nslookup google.com 8.8.8.8. Confirm both return the same IP — verifying your internal DNS server is not returning incorrect results.
  4. Run Test-NetConnection -ComputerName google.com -Port 443 in PowerShell. Confirm TcpTestSucceeded is True — this is your template for remotely testing any IIS port before escalating to the application team.
  5. Run netsh http show urlacl. On a machine with IIS installed, observe the URL reservations IIS has created (http://+:80/ or specific hostname prefixes). Each reservation corresponds to a website binding in IIS Manager.
💡
Test-NetConnection vs telnet

Telnet is not installed by default on Windows Server 2012+ and requires the Telnet Client feature. Test-NetConnection (PowerShell built-in) is the modern replacement — it tests TCP port connectivity, returns structured output (TcpTestSucceeded: True/False), shows route information, and works via PowerShell remoting without any additional installation. In scripts and automated health checks, always use Test-NetConnection. Use Test-NetConnection -ComputerName <host> -Port <port> -InformationLevel Detailed for the full diagnostic report.

🐛 Debugging Scenario

Failure: IIS is running and the site is configured correctly, but users from outside the network cannot reach it on port 80. Users inside the datacenter reach it fine.

🎯 Interview Questions

Beginner

What does netstat -ano tell you and what does each column mean?

netstat -ano combines three flags: -a (all connections and listening ports), -n (show numeric IP/port rather than resolving names — faster), -o (show the owning process ID). Output columns: Proto (TCP or UDP), Local Address (IP:port on this machine — 0.0.0.0 or :: means listening on all interfaces), Foreign Address (remote IP:port — 0.0.0.0:0 for listeners), State (LISTEN, ESTABLISHED, TIME_WAIT, CLOSE_WAIT, FIN_WAIT), PID. For IIS work: findstr LISTEN to see all open ports; findstr :80 to check who specifically owns port 80.

What is the difference between ping failure and port failure?

Ping failure (ICMP unreachable/timeout) means you cannot reach the host at Layer 3 (IP routing), the host is offline, or ICMP is blocked by a firewall. Port failure (Test-NetConnection or telnet refusing) means the host is reachable at IP level, but the specific TCP port is not open — either the application is not listening, the application crashed, or a firewall is blocking that specific port. IIS servers typically block ICMP in production (security hardening) while keeping ports 80/443 open. Always test the actual port before concluding a server is down based only on ping.

What is DNS and why is it important for IIS?

DNS (Domain Name System) is the distributed directory service that translates hostnames (www.example.com) to IP addresses (93.184.216.34). IIS is critical because: IIS uses Host Headers to route incoming requests to the correct site when multiple sites share one IP. If DNS resolves a hostname to the wrong IP, requests never reach the correct server. SSL certificates are issued for specific domain names — if DNS doesn't resolve to the cert's CN/SAN, browsers show certificate errors. During failover or IP changes, DNS TTL determines how long until clients see the new address — short TTLs (300 seconds) allow faster failover for IIS migrations.

What is WinRM and what port does it use?

WinRM (Windows Remote Management) is Microsoft's implementation of the WS-Management protocol, enabling remote management commands and PowerShell remoting. It listens on port 5985 (HTTP transport, unencrypted but with Windows authentication) and port 5986 (HTTPS transport, encrypted). WinRM must be explicitly enabled on the target server: winrm quickconfig enables the listener and opens the firewall rule. Once enabled, administrators can run Enter-PSSession -ComputerName hostname for interactive remote shells or Invoke-Command for scripted remote execution — critical for managing IIS in automation pipelines and across server farms.

What does TIME_WAIT mean in netstat output on an IIS server?

TIME_WAIT is the TCP state after a connection has been closed from this machine's side. TCP requires a 4-minute wait (2 * Maximum Segment Lifetime) before the port/address tuple can be reused, ensuring all packets from the closed connection have drained from the network. For IIS: some TIME_WAIT connections are normal. Hundreds or thousands of TIME_WAIT connections per second indicate a high-throughput site or — if the count grows unbounded — a connection pool that is not reusing connections properly. In HTTP/1.0 without keep-alive, every request creates and tears down a connection, generating TIME_WAIT. Fix: ensure HTTP/1.1 keep-alive is enabled in IIS and ensure clients (reverse proxies, load balancers) use persistent connections.

Intermediate

How do you check if a specific port is open on a remote IIS server without logging in to it?

Use Test-NetConnection -ComputerName <hostname> -Port <port> from any Windows machine with network access. This is the most direct method — it attempts a full TCP 3-way handshake and reports TcpTestSucceeded: True or False. Alternatively: curl -v http://hostname:port for HTTP layer testing. From outside: online port checkers test from the internet perspective. For batch testing multiple ports: 80,443,8080 | ForEach-Object { Test-NetConnection -ComputerName web01 -Port $_ }. Combine with Select-Object ComputerName,RemotePort,TcpTestSucceeded for a readable matrix.

Explain what the netsh http show urlacl command reveals and why it matters for IIS.

HTTP.sys uses URL namespace reservations (URL ACLs) to determine which HTTP.sys-registered applications receive which URLs. Each entry shows: a URL prefix (e.g., http://+:80/) and which user account has Listen rights. IIS registers its sites here automatically when configured in IIS Manager. This matters when: (1) IIS refuses to start because another app already registered the URL (e.g., BranchCache, WCF, SQL Reporting Services all compete for http://+:80/). (2) A non-IIS .NET application (self-hosted WCF) fails with "address already in use" — actually it needs its own URL ACL reservation. (3) You need to remove a stale registration after uninstalling an application that still has a URL reserved.

What is SSL certificate binding and how does netsh http show sslcert help diagnose issues?

SSL certificate bindings in IIS associate a specific certificate (by thumbprint) with an IP+port combination in HTTP.sys. When a HTTPS request arrives, HTTP.sys uses this binding to present the correct certificate for the TLS handshake before any IIS application code runs. netsh http show sslcert shows all registered SSL certificate bindings: IP:port (or hostname:port for SNI), certificate hash (thumbprint), application GUID (identifies whether it's IIS or another app), and certificate store. Useful when: the browser shows "expired certificate" even after installing a new one (the old thumbprint is still in the SSL cert binding — update the IIS site binding to the new cert). Or when a site returns a different site's certificate (SNI misconfiguration).

How does RDP work and what are its security risks on an IIS server?

Remote Desktop Protocol (RDP) allows graphical remote sessions to Windows servers over TCP port 3389 (default). RDP sessions are encrypted using TLS. Security risks: (1) Brute force attacks against local/domain credentials on exposed port 3389 — mitigate with account lockout and NLA (Network Level Authentication, enabled by default on Server 2016+). (2) BlueKeep and other RDP CVEs — keep OS patched. (3) Lateral movement — if an attacker gains RDP access, they can pivot to other systems. Mitigations for IIS servers: restrict RDP access to management VLAN only, require MFA (via Azure AD or NPS with RADIUS), use Just-in-Time (JIT) access via Azure Security Center, or replace with Windows Admin Center over HTTPS.

How do you set up PowerShell Remoting securely for IIS management across a server farm?

Secure WinRM setup: (1) Enable WinRM with HTTPS only: winrm quickconfig -transport:https — requires a valid SSL certificate on the target. (2) Configure HTTPS listener with a certificate: winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Hostname="server01.corp.com"; CertificateThumbprint="AABBCC..."}. (3) Restrict to specific admin accounts via WinRM access policy. (4) At enterprise scale, deploy via GPO: Computer Configuration → Windows Settings → Security Settings → Windows Firewall with Advanced Security (allow port 5986 from management VLAN). (5) Use JEA (Just Enough Administration) to restrict what remote users can do: define role capability files limiting commands to IIS-specific operations only — admins can restart app pools but cannot access the file system or modify security settings.

Scenario-based

IIS is not responding on port 443. Walk me through the complete diagnostic from outside the server to inside.

Layer by layer: 1. From client: Test-NetConnection -ComputerName webserver -Port 443 → TcpTestSucceeded: False. 2. On server (RDP in): netstat -ano | findstr :443 → no listener on 443. IIS is not listening. 3. sc query http → Running. HTTP.sys is up. 4. Open IIS Manager → sites → check the HTTPS binding exists. If missing → add it. 5. If binding exists: netsh http show sslcert — does 0.0.0.0:443 or the site's IP:443 appear? If missing, the SSL cert binding was deleted. Re-add in IIS Manager → Bindings → Edit → select correct certificate. 6. If the certificate thumbprint in the registry points to a deleted/expired cert, the binding will fail silently. Install a valid cert, then update the binding. Test with curl -v -k https://localhost after each change.

Users can access the IIS site by IP but not by hostname. What do you investigate?

This is a DNS and/or Host Header configuration problem. Steps: 1. nslookup mysite.example.com from the client — does it resolve? If no resolution: DNS record missing. Create an A record pointing the hostname to the server IP. 2. If it resolves but to wrong IP — stale DNS record. Update the A record and flush DNS: ipconfig /flushdns. 3. If DNS resolves correctly but site still won't load: check IIS Site Bindings — if the site binding has a specific Host Name set (e.g., mysite.example.com), requests arriving with the wrong Host header are rejected. If Host Name is blank in the binding, IIS accepts any hostname for that IP:port. 4. If multiple sites on the same IP: the site must have the correct hostname in its binding to distinguish it from the default site. This is a classic misconfiguration in multi-tenant IIS environments.

You see 10,000 CLOSE_WAIT connections in netstat on an IIS server hosting an API. What does this mean and what do you do?

CLOSE_WAIT means the remote end (clients) has closed the TCP connection (sent FIN to the server) but the local application (w3wp.exe) has not yet closed its end. It is waiting for the application to call close() on the socket. Large numbers of CLOSE_WAIT accumulating (not cycling back to CLOSED) indicate a socket leak in the application — the worker process is not properly closing connections after the client disconnects. Root cause: application holding database connections or upstream API connections open even after the client request ends. Fix: ensure all HttpClient, SqlConnection, and stream objects are properly disposed (using statements in .NET). Check IIS keep-alive settings — if clients are disconnecting because of aggressive timeout but the server-side code loops waiting for more data, it will build CLOSE_WAIT. Schedule a w3wp recycle as immediate mitigation to release the leaked sockets.

Two teams both claim they need IIS to use port 80 for their web applications on the same server. Is this possible? If so, how?

Yes, via IIS Host Head Bindings. HTTP.sys owns port 80 and routes incoming requests based on the HTTP Host header. Configure each site in IIS with the same port but different Host Name values: Site A → port 80, hostname: app1.company.com. Site B → port 80, hostname: app2.company.com. When a request for app1.company.com arrives, HTTP.sys inspects the Host header and routes only to Site A's app pool. Both sites coexist on port 80. Requirements: DNS must resolve each hostname correctly, each site's binding must have the hostname field populated (otherwise IIS creates an ambiguous binding and only one site will catch requests). For HTTPS: SNI (Server Name Indication) is the equivalent mechanism, allowing different SSL certificates per hostname on port 443.

How do you connect to an IIS server remotely via PowerShell and run IISRESET without full RDP access?

With WinRM enabled on the target, use: Invoke-Command -ComputerName webserver01 -ScriptBlock { iisreset }. This runs iisreset on the remote server and streams the output back to your console. For persistent sessions: $session = New-PSSession -ComputerName webserver01; Invoke-Command -Session $session -ScriptBlock { Import-Module WebAdministration; Restart-WebAppPool "MyPool" }. Security best practice: if the executing account is already a member of the local Administrators group on the remote server via domain group membership, WinRM uses Kerberos authentication automatically — no credentials need to be embedded in scripts. Use JEA (Just Enough Administration) to create a restricted endpoint that only exposes IIS management cmdlets if you want to grant restartability without full admin rights.

🌐 Real-world Usage

Network diagnostic tools are the scaffolding that every IIS incident response uses to isolate the failure domain. In a modern cloud-native or hybrid enterprise, IIS servers sit behind load balancers, WAFs, CDNs, and firewalls — a connectivity problem can originate at any of these layers. Being fluent in these tools lets you point to the exact network hop or service that broke, avoiding hours of unproductive back-and-forth between network team, security team, and development team.

📝 Summary

Use ping/tracert for IP-layer reachability, netstat/Test-NetConnection for port-level analysis, nslookup/Resolve-DnsName for DNS verification, and curl for end-to-end HTTP testing. netsh http commands expose HTTP.sys internals that no other tool shows. WinRM/PowerShell Remoting enables management automation across IIS farms without GUI access.