Bookmark this page

Guided Exercise: Verifying Network Connectivity

Use some software tools to test network connectivity.

Outcomes

You should be able to use software tools to test network connectivity.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise.

[student@workstation ~]$ lab start network-testing

This command installs the required packages and enables the network ports through a firewall.

Instructions

  1. Log in to servera and switch to the root user.

    [student@workstation ~]$ ssh student@servera
    ...output omitted...
    [student@servera ~]$ sudo -i
    [sudo] password for student: student
    [root@servera ~]#
  2. Test the network connectivity from the servera system to the serverb system with the ping command.

    [root@servera ~]# ping -c 2 serverb.lab.example.com
    PING serverb.lab.example.com (172.25.250.11) 56(84) bytes of data.
    64 bytes from serverb.lab.example.com (172.25.250.11): icmp_seq=1 ttl=64 time=0.433 ms
    64 bytes from serverb.lab.example.com (172.25.250.11): icmp_seq=2 ttl=64 time=0.457 ms
    
    --- serverb.lab.example.com ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1036ms
    rtt min/avg/max/mdev = 0.433/0.445/0.457/0.012 ms
  3. Use the nmap command to scan network ports.

    1. Install the nmap package if it is not already installed on the servera system.

      [root@servera ~]# yum install nmap
      ...output omitted...
      Complete!
    2. Scan the 172.25.250.0/24 network to identify reachable systems in the network.

      [root@servera ~]# nmap -sn 172.25.250.0/24
      Starting Nmap 7.70 ( https://nmap.org ) at 2021-10-25 10:14 EDT
      Nmap scan report for workstation.lab.example.com (172.25.250.9)
      Host is up (0.00078s latency).
      MAC Address: 52:54:00:00:FA:09 (QEMU virtual NIC)
      Nmap scan report for serverb.lab.example.com (172.25.250.11)
      Host is up (0.0022s latency).
      MAC Address: 52:54:00:00:FA:0B (QEMU virtual NIC)
      Nmap scan report for workstation.lab.example.com (172.25.250.254)
      Host is up (0.0010s latency).
      MAC Address: 52:54:00:00:FA:FE (QEMU virtual NIC)
      Nmap scan report for servera.lab.example.com (172.25.250.10)
      Host is up.
      Nmap done: 256 IP addresses (4 hosts up) scanned in 3.77 seconds
    3. Scan for IPv4 ports on the serverb system.

      [root@servera ~]# nmap serverb.lab.example.com
      Starting Nmap 7.70 ( https://nmap.org ) at 2021-10-26 03:02 EDT
      Nmap scan report for serverb.lab.example.com (172.25.250.11)
      Host is up (0.00041s latency).
      Not shown: 996 filtered ports
      PORT     STATE  SERVICE
      22/tcp   open   ssh
      80/tcp   open   http
      443/tcp  open   https
      9090/tcp closed zeus-admin
      MAC Address: 52:54:00:00:FA:0B (QEMU virtual NIC)
      
      Nmap done: 1 IP address (1 host up) scanned in 16.12 seconds
  4. Use the ncat command to send content from the servera system to the serverb system.

    1. From the workstation system, open another terminal, log in to the serverb system, and switch to the root user.

      [student@workstation ~]$ ssh student@serverb
      ...output omitted...
      [student@serverb ~]$ sudo -i
      [sudo] password for student: student
      [root@serverb ~]#
    2. The start script of this exercise uses the firewall-cmd command to open the 4231/tcp network port on the serverb system. Run the ncat command on the serverb system to listen for packets from the servera system on port 4231.

      [root@serverb ~]# ncat -l -k 4231
    3. Return to the servera system. Use the nmap command to scan for ports on the serverb system.

      [root@servera ~]# nmap -p4000-4999 serverb
      Starting Nmap 7.70 ( https://nmap.org ) at 2021-10-26 03:06 EDT
      Nmap scan report for serverb (172.25.250.11)
      Host is up (0.00050s latency).
      rDNS record for 172.25.250.11: serverb.lab.example.com
      Not shown: 999 filtered ports
      PORT     STATE SERVICE
      4231/tcp open  vrml-multi-use
      MAC Address: 52:54:00:00:FA:0B (QEMU virtual NIC)
      
      Nmap done: 1 IP address (1 host up) scanned in 12.25 seconds
    4. From the servera system, use the ncat command to connect to port 4231/tcp on the serverb system. Type a line of text, and then press Enter. Exit the prompt by typing Ctrl+C.

      [root@servera ~]# ncat serverb 4231
      This is a test
      Ctrl+C
    5. Return to the serverb system and verify that the text is displayed. Exit from the ncat prompt by typing Ctrl+C.

      [root@serverb ~]# ncat -l -k 4231
      This is a test
      Ctrl+C
    6. Close the additional terminal, and return to workstation as the student user.

      [root@serverb ~]# exit
      [student@serverb ~]$ exit
      [student@workstation ~]$
  5. On the servera system, install the iptraf-ng package if it is not already installed.

    [root@servera ~]# yum install iptraf-ng
    ...output omitted...
    Complete!
  6. Start the iptraf-ng application for network monitoring.

    [root@servera ~]# iptraf-ng

    Use the arrow keys to navigate, and then press Enter to choose the highlighted menu item.

  7. Select IP traffic monitor in the main menu. In the Select Interface dialog, select All interfaces for monitoring network traffic. The top frame shows all TCP connections. The bottom frame shows other types of packets.

  8. Press X to return to the main menu in the iptraf-ng command interface.

  9. Display network interface statistics with the iptraf-ng command.

    1. Select General interface statistics, or press S to display interface statistics.

    2. On the workstation machine, open another terminal, log in to the servera system, and switch to the root user. Use the following command to generate some network traffic.

      [student@workstation ~]$ ssh student@servera
      ...output omitted...
      [student@servera ~]$ sudo -i
      [sudo] password for student: student
      [root@servera ~]# ls -R /usr
      ...output omitted...

      Watch the traffic counters change. The packet count starts increasing, and activity for eth0 rises.

    3. Press X and return to the main menu.

  10. Create a filter to exclude SSH traffic, but monitor all other network traffic:

    • Select Filters, and then select IP. In this screen, you can create and manage IP network filters.

    • Select Define new filter and enter Exclude SSH in the description box, and then press Enter. An empty list of filtering rules appears.

    • Create a rule to exclude all incoming SSH traffic destined for port 22. Press A to add a new rule to the list of rules for this filter.

    • Use Tab to navigate and enter 22 in the first of the two Port fields of the Destination column. In the TCP field in the Protocols to match section, enter Y. In the Include/Exclude field, enter E.

    • Press Enter to accept the changes.

    • Create another rule to include all other network traffic. Press A to add another rule to the list of rules for this filter.

    • Enter Y in the All IP protocol field in the Protocols to match section. Press Enter to accept the changes.

    • Press X to exit the rule definition screen.

    • To apply the created filter, select Apply filter, and then select the Exclude SSH filter.

    • Press X to exit the Filters menu.

    • In the Filter Status frame, IP filter active confirms that the filter is in effect.

    • Press X to exit the Filter Status menu.

    • To verify the newly created filter, select IP traffic monitor, and then select All interfaces for the interface.

    1. From the newly created SSH session to the servera machine, log out and log in to the servera machine as the root user.

      [root@servera ~]# exit
      logout
      [student@servera ~]$ exit
      logout
      Connection to servera closed.
      [student@workstation ~]$ ssh root@servera
      ...output omitted...
      [root@servera ~]#

      Return to the terminal that is running the iptraf-ng command and verify that the SSH in the TCP connection does not appear in the top frame. The Packets captured counter at the bottom of the screen still increases.

    2. Return to the servera machine. Use the curl command to connect to serverb.lab.example.com.

      [root@servera ~]# curl serverb.lab.example.com
      Welcome to serverb

      Return to the terminal that is running the iptraf-ng command and check that a temporary connection 172.25.250.11:80 appears in the top frame. An HTTP connection uses a TCP connection. The HTTP connection is displayed because it did not match the first rule in the active filter.

    3. Close the servera terminal.

      [root@servera ~]# exit
      [student@workstation ~]$ exit
  11. Return to the terminal where the iptraf-ng tool is running. Press X to go to the main menu.

  12. In the iptraf-ng window, detach and delete the Exclude SSH filter:

    • Select Filters and then select IP. Now select Detach filter. A message appears with IP filter deactivated.

    • Press X to exit.

    • Select Delete Filter and select Exclude SSH.

    • Press X twice and return to Filter status.

    • The Filter status changes to No IP filter active.

    • Press X and return to the main menu.

    • Select IP traffic monitor, and then select All interfaces. Monitoring now shows the active SSH connections.

    • Press X and return to the main menu, and then press X again to exit the application.

  13. Return to workstation as the student user.

    [root@servera ~]# exit
    [student@servera ~]$ exit
    [student@workstation ~]$

Finish

On the workstation machine, use the lab command to complete this exercise. This is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish network-testing

Revision: rh342-8.4-6dd89bd