Professional Documents
Culture Documents
CNIOT Lab Assignment
CNIOT Lab Assignment
Assignment – 01 & 02
The objective of the lab assignments 01 and 02 is to make the students familiar with the general and
networking commands used in UNIX/Linux and Windows operating systems.
1. Environment Setup
To practice the general and networking commands one may use 1) A computer with UNIX/LINUX and
Windows Installed, 2) A virtual machine environment with Linux and windows installed; or 3) Online platforms.
If one does not have the choice of using options 1 or 2, here is the list of online resources for practice. One
needs to register in corresponding websites to utilize the services of online simulators/emulators. Read and
follow the instructions in the websites given below to utilize the services.
2. UNIX/LINUX Commands
pwd prints working directory (prints to screen, ie displays the full path, or your location on the filesystem) ls lists contents of current
directory
ls –l lists contents of current directory with extra details
ls /home/user/*.txt lists all files in /home/user ending in .txt
cd - change directory to the last directory you were in before changing to wherever you are now mkdir mydir makes a directory
called mydir
rm –f myfile removes myfile without asking you for confirmation. useful if using wildcards to remove files *** cp –r dir newdir copies the
whole directory dir to newdir. –r must be specified to copy directory contents recursively rm –rf mydir this will delete directory mydir
along with all its content without asking you for confirmation! *** nano opens a text editor. see ribbon at bottom for help. ^x means CTRL-
x. this will exit nano nano new.txt opens nano editing a file called new.txt
more new.txt displays the contents of new.txt screen by screen. spacebar to pagedown, q to quit head new.txt displays
first 10 lines of new.txt
tail –f new.txt displays the contents of a file as it grows, starting with the last 10 lines. ctrl-c to quit. mv myfile newlocdir
moves myfile into the destination directory newlocdir
mv myfile newname renames file to newname. if a file called newname exists, this will overwrite it! mv dir subdir
moves the directory called dir to the directory called subdir
mv dir newdirname renames directory dir to newdirname
top displays all the processes running on the machine, and shows available resources du –h --max-depth=1 run this in your
home directory to see how much space you are using. don’t exceed 5GB ssh servername goes to a different server. this
could be queso, brie, or provolone
grep pattern files searches for the pattern in files, and displays lines in those files matching the pattern date shows the
current date and time
anycommand > myfile redirects the output of anycommand writing it to a file called myfile
date > timestamp redirects the output of the date command to a file in the current directory called timestamp anycommand >>
myfile appends the output of anycommand to a file called myfile
date >> timestamp appends the current time and date to a file called timestamp. creates the file if it doesn’t exist command1 |
command2 “pipes” the output of command1 to command2. the pipe is usually shift-backslash key date | grep Tue displays any line in
the output of the date command that matches the pattern Tue. (is it Tuesday?) tar -zxf archive.tgz this will extract the contents of the
archive called archive.tgz. kind of like unzipping a zipfile. *** tar -zcf dir.tgz dir this creates a compressed archive called dir.tgz that
contains all the files and directory structure of dir
time anycommand runs anycommand, timing how long it takes, and displays that time to the screen after completing anycommand man
anycommand gives you help on anycommand
*** = use with extreme caution! you can easily delete or overwrite important files with these.
cp myfile ../newname copies myfile to the parent directory and names the copy newname cp
/home/turnersd/scripts/bstrap.pl . copies bstrap.pl to “.” i.e. to dot, or the current directory you’re in cp myfile
~/subdir/newname copies myfile to subdir in your home, naming the copy newname
more ../../../myfile displays screen by screen the content of myfile, which exists 3 directories “up”
Refer the link [9] for some more commands to practice on Linux/Unix operating
systems. 3. Windows Commands
4. Networking Commands
Ping – Ping is probably the most familiar of networking command line tools. With it, you are able to send an
echo request to a device locally, or on the Internet, and receive a reply.
Netstat – Stands for Network Statistics, this command will display connection information, routing tables and so
on. Entering the command will display what’s going on while you use the network and Internet. Use netstat -e
for interface stats.
Arp – Stands for Address Resolution Protocol displays and modifies entries in the ARP cache, which contains
one or more tables that are used to store IP addresses and their resolved Ethernet or Token Ring physical
addresses.
NbtStat – The nbtstat command is a diagnostic tool for NetBIOS over TCP/IP. Its primary design is to help
troubleshoot NetBIOS name resolution problems. It’ll display the human-friendly names of devices on the
network along with their IP addresses.
Hostname – If you’re struggling to find the name of a Windows computer you’ve got on your network, simply
enter the hostname command and it’ll display the computer’s local name.
Tracert – Stands for Trace Route will examine the path to a remote computer, either locally or on the Internet.
For example, entering tracert google.com will display the hops taken over networking devices to get to one of
the Google servers.
Ipconfig – Probably one of the most used networking command in Windows. Ipconfig will display information on
the local computer’s network interfaces, such as IP addresses (both IPv4 and IPv6), Hostname, gateway and
so on.
Nslookup – This tool can be used to look up the and diagnose the Domain Name System (DNS) of a location
on the local network or Internet.
Route – The Windows Route command allows you to view the device’s routing tables. To do so, simply type
Route Print. This will print the network interfaces, IPv4 and IPv6 route tables.
Pathping – This is a handy command that combines the best elements of Ping and Tracert. It will display the
latency and packet loss between one computer and another (either locally or on the Internet), and after 300
seconds display a detailed report.
Getmac – Every network interface has a unique Media Access Code assigned to it. Some routers are able to
limit connection to the network by only allowing user-entered MAC addresses in. You can get the MAC address
of a windows computer by entering getmac.
Netsh – This is a complex command that when entered will put you into a different shell, the Network Shell
(netsh). It’s capable of displaying and configuring information regarding a computer’s networking setup.
Telnet – This is a command that can be used to connect to another computer, or manage a router or switch.
You can send and receive files, send command and much more. With Telnet you’re also able to connect to
active Bulletin Board Systems. For example, enter: telnet jiit.ac.in
Refer the link [3] and practice the Linux networking commands
Refer the link [5] for some more networking commands related to 1) General networking; 2) Network
Configuration; 3) Internet Specific Commands; and 4) Remote Administration.
5. Network Scanning
NMAP (Network mapper) is a tool popularly used for network scanning. One may download the nmap tool from
its official website [11] according to the operating system. Refer the link [10] for its usage and practice the
following scanning techniques
Refer the link [12] for video lecture on NAMP tool for basic network scanning.
6. Linux Firewalls
IPTABLES was explained in this section for describing configuration of Linux Firewalls. The given
instructions are w.r.t to Debian based LINUX. Use admin/root privileges to work with iptables. Refer the
link [13] for video lecture on iptables. Further, to practice the linux firewall settings, one may use the
online service available with link [14].
1. Installation
2. If you update your firewall rules and want to save the changes
8. To block an IP address
SSH - 22
Telnet - 23
HTTP - 80
HTTPS - 443
SMTP - 25
POP3 - 110
POP3S - 995
MySQL - 3306
PostgreSQL - 5432
IMAP - 143
SSH
iptables -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j
ACCEPT iptables -A OUTPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j
ACCEPT
Telnet
iptables -A INPUT -p tcp --dport 23 -m conntrack --ctstate NEW,ESTABLISHED -j
ACCEPT iptables -A OUTPUT -p tcp --sport 23 -m conntrack --ctstate ESTABLISHED -j
ACCEPT
HTTP
By specification
iptables -S
iptables -S TCP
iptables -L
Listing INPUT rules
iptables -L INPUT
iptables -L INPUT -v
iptables -L --line-numbers
Flushing chains
sudo iptables -F
vim /etc/network/interfaces
# NAT
auto eth0
iface eth0 inet dhcp
# Host-only
auto eth1
iface eth1 inet dhcp
13. Providing internet on a LAN (eth0 has internet and eth1 is LAN subnet)
echo 1 /proc/sys/net/ipv4/ip_forward
Next, edit /etc/sysctl.conf and change the line that says net.ipv4.ip_forward = 0 to net.ipv4.ip_forward =
1. and reboot the system.
Refer the links [15-18] for more information on iptables firewall settings.
7. References
[1] https://download.microsoft.com/download/5/8/9/58911986-D4AD-4695-BF63-F734CD4DF8F2/ws
commands.pdf
[2] https://www.computervillage.org/articles/CommandLine.pdf
[3] https://www.javatpoint.com/linux-networking-commands
[4] https://www.computernetworkingnotes.com/networking-tutorials/basic-networking-commands-explained with-
examples.html
[5] https://tldp.org/LDP/GNU-Linux-Tools-Summary/html/c8319.htm
[6] https://www.actualtechmedia.com/wp-content/uploads/2017/12/CUMULUS-NETWORKS-Linux101.pdf [7]
https://groups.inf.ed.ac.uk/tulips/projects/1617/mjartan.pdf
[8] Linux/Unix Command Line Cheat Sheet - GettingGeneticsDone.blogspot.com
[9] http://www.tjhsst.edu/~dhyatt/superap/unixcmd.html
[10]https://nmap.org/bennieston-tutorial/
[11]https://nmap.org/
[12]NMAP tool for basic network scanning: https://youtu.be/MK7WPH79gR8
[13]Configuring Linux firewall iptables https://youtu.be/ADemvnfXjP8
[14]https://groups.inf.ed.ac.uk/tulips/projects/1617/FirewallWebApp/
[15]From HowToGeek by : Korbin Brown https://www.howtogeek.com/177621/the-beginners-guide-to-iptables the-linux-
firewall/
[16]From nixCraft - 25 iptables Examples https://www.cyberciti.biz/tips/linux-iptables-examples.html/ [17] Here is
Juniper Networks instructions on implementing a Stateful Firewall on their hardware devices. Take few minutes and
compare this with what you have already learned about iptables.
https://www.juniper.net/documentation/en_US/junos/topics/usage-guidelines/services-configuring-stateful firewall-
rules.html/
[18]https://www.digitalocean.com/community/tutorials/a-deep-dive-into-iptables-and-netfilter
architecture#:~:text=The%20Mangle%20Table,be%20altered%20in%20similar%20ways.