Page List

Wednesday, June 12, 2024

CBT Nugget: Linux Server Administration - 9. Testing Network Connectivity

Testing Network Connectivity

Network connectivity testing is essential for diagnosing and resolving network issues. Various tools and commands can help verify the status and performance of network connections. Below is a comprehensive guide to testing network connectivity.

Basic Connectivity Tests

  1. ping:

    • Used to check if a remote host is reachable and measure round-trip time for packets.

    Example:

    sh
    ping -c 4 example.com

    Output:

    plaintext
    PING example.com (93.184.216.34): 56 data bytes 64 bytes from 93.184.216.34: icmp_seq=0 ttl=56 time=15.2 ms 64 bytes from 93.184.216.34: icmp_seq=1 ttl=56 time=14.9 ms 64 bytes from 93.184.216.34: icmp_seq=2 ttl=56 time=15.0 ms 64 bytes from 93.184.216.34: icmp_seq=3 ttl=56 time=15.1 ms --- example.com ping statistics --- 4 packets transmitted, 4 packets received, 0.0% packet loss
  2. traceroute:

    • Traces the path packets take to reach a remote host.

    Example:

    sh
    traceroute example.com

    Output:

    plaintext
    traceroute to example.com (93.184.216.34), 30 hops max, 60 byte packets 1 192.168.1.1 (192.168.1.1) 1.153 ms 1.166 ms 1.159 ms 2 10.0.0.1 (10.0.0.1) 9.254 ms 9.270 ms 9.264 ms 3 example.com (93.184.216.34) 15.265 ms 15.278 ms 15.272 ms
  3. nslookup and dig:

    • Query DNS to resolve domain names to IP addresses and vice versa.

    nslookup Example:

    sh
    nslookup example.com

    Output:

    plaintext
    Server: 192.168.1.1 Address: 192.168.1.1#53 Non-authoritative answer: Name: example.com Address: 93.184.216.34

    dig Example:

    sh
    dig example.com

    Output:

    plaintext
    ; <<>> DiG 9.11.3-1ubuntu1.13-Ubuntu <<>> example.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22606 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; QUESTION SECTION: ;example.com. IN A ;; ANSWER SECTION: example.com. 299 IN A 93.184.216.34 ;; Query time: 23 msec ;; SERVER: 192.168.1.1#53(192.168.1.1) ;; WHEN: Wed Jun 12 10:20:23 UTC 2024 ;; MSG SIZE rcvd: 56

Advanced Connectivity Tests

  1. telnet and nc (netcat):

    • Check if specific ports on a remote host are open.

    telnet Example:

    sh
    telnet example.com 80

    Output:

    plaintext
    Trying 93.184.216.34... Connected to example.com. Escape character is '^]'.

    netcat (nc) Example:

    sh
    nc -zv example.com 80

    Output:

    plaintext
    Connection to example.com 80 port [tcp/http] succeeded!
  2. ifconfig and ip:

    • Display and configure network interfaces.

    ifconfig Example:

    sh
    ifconfig

    Output:

    plaintext
    eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::a00:27ff:fe4e:66a prefixlen 64 scopeid 0x20<link> ether 08:00:27:4e:66:6a txqueuelen 1000 (Ethernet) RX packets 156 bytes 20526 (20.5 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 148 bytes 19582 (19.5 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

    ip Example:

    sh
    ip addr

    Output:

    plaintext
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 08:00:27:4e:66:6a brd ff:ff:ff:ff:ff:ff inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::a00:27ff:fe4e:66a/64 scope link valid_lft forever preferred_lft forever
  3. ethtool:

    • Display or change Ethernet device settings.

    Example:

    sh
    sudo ethtool eth0

    Output:

    plaintext
    Settings for eth0: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Supported pause frame use: No Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Advertised pause frame use: No Advertised auto-negotiation: Yes Speed: 100Mb/s Duplex: Full Port: Twisted Pair PHYAD: 1 Transceiver: internal Auto-negotiation: on MDI-X: Unknown
  4. mtr:

    • Combines the functionality of ping and traceroute to diagnose network issues.

    Example:

    sh
    mtr example.com

    Output:

    plaintext
    Start: 2024-06-12T10:20:23+0000 HOST: hostname Loss% Snt Last Avg Best Wrst StDev 1. 192.168.1.1 0.0% 10 0.4 0.4 0.4 0.5 0.0 2. 10.0.0.1 0.0% 10 9.2 9.3 9.2 9.4 0.0 3. example.com 0.0% 10 15.1 15.0 14.9 15.1 0.0

Example Scenario

Diagnosing Network Connectivity Issue:

  1. Ping the Gateway:

    sh
    ping -c 4 192.168.1.1
  2. Traceroute to an External Host:

    sh
    traceroute 8.8.8.8
  3. Check DNS Resolution:

    sh
    nslookup example.com
  4. Verify Interface Configuration:

    sh
    ip addr show eth0
  5. Check Ethernet Device Settings:

    sh
    sudo ethtool eth0
  6. Diagnose with mtr:

    sh
    mtr 8.8.8.8

Summary

Testing network connectivity involves using a combination of tools to diagnose and resolve issues. Basic commands like ping, traceroute, nslookup, and dig help verify connectivity and DNS resolution. Advanced tools like telnet, netcat, ifconfig, ip, ethtool, and mtr provide deeper insights into network configurations and performance. By systematically using these tools, you.

驻讜住讟 诪讜爪讙

CBT Nugget: Linux Server Administration - 13.Identifying Red Hat and CentOS Network Configuration Files

13.Identifying Red Hat and CentOS Network Configuration Files In Red Hat Enterprise Linux (RHEL) and CentOS, network configuration is manag...