0% found this document useful (0 votes)
3 views

Tutorial Exercise 1

The document outlines an exercise to study and execute basic networking commands in Windows and Linux, including ipconfig/ifconfig, ping, traceroute, netstat, and nslookup. It provides detailed procedures for recording network information and interpreting command outputs. The exercise concludes with a practice task to create a program that utilizes a network command to display information based on user input.

Uploaded by

jaidarsh1983
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Tutorial Exercise 1

The document outlines an exercise to study and execute basic networking commands in Windows and Linux, including ipconfig/ifconfig, ping, traceroute, netstat, and nslookup. It provides detailed procedures for recording network information and interpreting command outputs. The exercise concludes with a practice task to create a program that utilizes a network command to display information based on user input.

Uploaded by

jaidarsh1983
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Exercise-1 BASIC NETWORKING COMMANDS

4.07.2024

Aim:
To study and execute the basic networking commands in Windows and Linux

Software:
Command Prompt (Windows) and Terminal (Linux)

Procedure:

ipconfig/ ifconfig Command

ipconfig (windows) / ifconfig (Linux) utility is used to configure network interface


parameters. Mostly we use this command to check the IP address assigned to the system.

Windows

19L505 COMPUTER NETWORKS Page 1


Linux

Note: The screen will show the IP address, subnet mask and the default gateway. The IP address and
the default gateway should be in the same network or subnet; otherwise this host wouldn’t be able
to communicate outside the network.

a. Record the following information for the computer.

IP address: 10.1.224.107

Subnet mask: 255.255.248.0

Default gateway: 10.1.224.10

IP address: 10.0.2.15

Subnet mask: 255.255.255.0

Default gateway: 10.0.2.255

b. To see more information, type ipconfig/all (Windows) OR ifconfig –a (Linux) and press Enter key. It
will show the detailed IP configuration of the computer on the screen.

19L505 COMPUTER NETWORKS Page 2


Windows

19L505 COMPUTER NETWORKS Page 3


Linux:

Record the following

Host name (computer name): Dell

Physical address of the machine: 0A-00-27-00-00-0A


c. Compare your result with a few nearby computers. What similarities do you see in the physical (MAC)
address?
There is no similarity in MAC address, as it is unique.

Ping Command

The ping command is one of the most often used networking utilities for detecting
devices on a network and for troubleshooting network problems. When you ping a device
you send that device a short message, which it then sends back (the echo). Ping uses the
Internet Control Message Protocol (ICMP) echo-request and echo-reply feature to test the
physical connectivity.

The general format is ping <hostname> or ping <IPaddress>

a. Ping to the Google Server. Open command prompt (Windows)/Terminal(Linux) and type ping
<IPaddress or google.com>. Note the result (in both Windows and Linux)

Windows

19L505 COMPUTER NETWORKS Page 4


Linux

b. Ping the computer’s loopback IP address. Type the following command: ping 127.0.0.1

The address 127.0.0.1 is reserved for loopback testing. If the ping is successful, then TCP/IP is
properly installed and functioning on this computer.

Windows

19L505 COMPUTER NETWORKS Page 5


Linux

Traceroute Command

Traceroute or tracert command shows the path a packet of information takes from your
computer to one you specify. It will list all the routers it passes through until it reaches its
destination, or fails to and is discarded. In addition to this, it will tell you how long each 'hop'
from router to router takes.

Note: Destination host or IP is mandatory parameter to use this utility.

a. Trace the route to the psgtech website. Try in both windows and Linux. Record the output and
interpret.

Windows

19L505 COMPUTER NETWORKS Page 6


Try out any other two network commands in Windows and Linux. Mention its functions and
record the output.

NETSTAT

19L505 COMPUTER NETWORKS Page 7


Netstat is a command-line utility in Windows, Linux, and other operating systems that
displays active network connections, routing tables, and interface statistics. It provides
information on:

1. Active connections (TCP, UDP, etc.)

2. Protocol statistics (e.g., IP, IPv6, ICMP)

3. Interface statistics (e.g., Ethernet, Wi-Fi)

4. Routing table entries

The command "netstat" is often used for troubleshooting network issues, monitoring network
activity, and identifying potential security risks.

Some common uses of netstat include:

- Checking which ports are in use

- Identifying the source and destination of network traffic

- Verifying network connectivity

- Detecting potential security threats (e.g., open ports, unknown connections)

windows

19L505 COMPUTER NETWORKS Page 8


Linux:

NSLOOKUP:

Nslookup is a command-line tool used to query DNS (Domain Name System) servers and display
information about domain names, IP addresses, and mail servers. It's a useful tool for
troubleshooting DNS issues, verifying domain information, and debugging network connectivity
problems

WINDOWS:

19L505 COMPUTER NETWORKS Page 9


LINUX:

19L505 COMPUTER NETWORKS Page 10


Practice Task-1: Interactive Network Command with User Input

Write a program in a programming language of your choice that utilizes a network


command and user input to display network information in a user-friendly format.

import subprocess

import re

import os

def ping_host():

host = input("Enter a hostname or IP address to ping: ")

19L505 COMPUTER NETWORKS Page 11


command = ["ping", "-n", "4", host]

try:

output = subprocess.check_output(command, stderr=subprocess.STDOUT,


universal_newlines=True)

packets_info_windows = re.search(r'Packets: Sent = (\d+), Received = (\d+), Lost =


(\d+) \((\d+)% loss\)', output)

rtt_info_windows = re.search(r'Average = (\d+)ms', output)

if packets_info_windows:

print("\nPing Results for", host)

print(f"Packets: Sent = {packets_info_windows.group(1)}, Received =


{packets_info_windows.group(2)}, Lost = {packets_info_windows.group(3)}
({packets_info_windows.group(4)}% loss)")

if rtt_info_windows:

print("RTT (ms): Average =", rtt_info_windows.group(1), "ms")

else:

print("Ping command failed to retrieve RTT information.")

else:

print("Ping command failed to retrieve packet information.")

except subprocess.CalledProcessError as e:

print("Ping command failed. Please check the hostname or IP address and try
again.")

print("Error output:", e.output)

except Exception as e:

print("An unexpected error occurred:", e)

19L505 COMPUTER NETWORKS Page 12


if __name__ == "__main__":

ping_host()

Result:
The basic network commands has been studied, executed in Windows and Linux.

19L505 COMPUTER NETWORKS Page 13

You might also like