Checking network connectivity

One of the first things you can do in terms of troubleshooting is to determine whether you have network connectivity between your hosts.

Getting ready

This recipe uses servers in the Reskit.Org domain (DC1, DC2, SRV1, and SRV2)that you have previously installed. Run this recipe on SRV1.

How to do it...

  1. Use Test-Connection to test the connection to DC1:
    Test-Connection -ComputerName DC1
  2. Redo the test with a simple true/false return:
    Test-Connection -ComputerName DC1 -Quiet
  3. Test multiple systems at once:
    Test-Connection -ComputerName 'DC1','DC2','SRV2' -Count 1
  4. Test the connectivity for SMB traffic with DC1:
    Test-NetConnection -ComputerName DC1 -CommonTCPPort SMB 
  5. Get a detailed connectivity check by using DC1 with HTTP:
    $TNCHT = @{
      ComputerName     = 'DC1'
      CommonTCPPort    = 'HTTP'
      InformationLevel = 'Detailed'
    }
    Test-NetConnection @TNCHT
  6. Look for a particular port (that is, SMB on DC1):
    Test-NetConnection -ComputerName DC1 -Port 445
  7. Look for a host that does not exist:
    Test-NetConnection -ComputerName 10.10.10.123
  8. Look for a host that exists but a port/application that does not exist:
    Test-NetConnection -ComputerName DC1 -PORT 9999

How it works...

In step 1, you checked the network connectivity from SRV1 to DC1 using the Test-NetConnection cmdlet, which looks like this:

How it works...

In step 2, you repeated this test using the -Quiet switch, which looks like this:

How it works...

In step 3, you used Test-Connection to test connections from SRV1 to multiple remote servers, which looks like this:

How it works...

The Test-NetConnection cmdlet provides additional parameters. In step 4, you tested whether SRV1 can reach the SMB server service on DC1. SRV1 uses this port to download group policy details. The output looks like this:

How it works...

You can also get a more detailed report of attempted connectivity. You can use the -InformationLevel parameter set to detailed so that you receive more information on the attempt to connect. In step 5, you checked whether SRV1 can create a HTTP connection with DC1, as follows:

How it works...

In step 6, you used Test-NetConnection to test the connectivity to a numbered port, port 389 on DC1. Port 389 is the LDAP port that an AD client uses to talk to a domain controller. The output of this step looks like this:

How it works...

There's more...

In step 2, you used the -Quiet switch with Test-NetConnection. This directs the cmdlet to just return a true or false value after attempting to connect to the remote system. This can be useful in scripts where you only need to check whether a server is contactable.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.147.193