Вы находитесь на странице: 1из 44

K. J.

Somaiya College of Engineering


Department of Computer Engineering
LIST OF EXPERIMENTS
Subject

: Open Source Lab - 1

Class

: M. E. Computer Engineering (Semester I)

Year

: 2012 - 2013 (First Term)

1. a. Installation of Linux OS in Dual boot Environment


b. Basic Linux Command Practice
2. a. Basic Linux Networking Commands
b. Multiple IP address to Single LAN
c. Adding Static Route in Routing table
d. Configure Linux Server as a Router and configure IP Forwarding
3.

Configuration of Linux as FTP and Web server

4.

Configuration of Linux as DNS Server

5.

Configuration of Linux as a Firewall, SNAT and DNAT

6.

IT Infrastructure monitoring using NEGIOS

7.

Virtualization on Linux

8.

Working With LaTeX

9. Mini Project Configuration of Private cloud using Open Source technology

Experiment no. 1a
Aim: Installation of Linux OS in Dual boot Environment
Theory:
GNU/Linux
Linux is an operating system: a series of programs that let you interact with your computer and run other programs.
Linux is modelled on the Unix operating system. From the start, Linux was designed to be a multi-tasking, multi-user
system. These facts are enough to make Linux different from other well-known operating systems. However, Linux is
even more different than you might imagine. In contrast to other operating systems, nobody owns Linux. Much of its
development is done by unpaid volunteers.
Linux users have immense freedom of choice in their software. For example, Linux users can choose from a dozen
different command line shells and several graphical desktops. This selection is often bewildering to users of other
operating systems, who are not used to thinking of the command line or desktop as something that they can change.
Linux is also less likely to crash, better able to run more than one program at the same time, and more secure than
many operating systems. With these advantages, Linux is the fastest growing operating system in the server market.
More recently, Linux has begun to be popular among home and business users as well.

Ubuntu
Ubuntu is a complete desktop Linux operating system, freely available with both community and professional support.
The Ubuntu community is built on the ideas enshrined in the Ubuntu Manifesto: that software should be available free
of charge, that software tools should be usable by people in their local language and despite any disabilities, and that
people should have the freedom to customize and alter their software in whatever way they see fit.

Ubuntu will always be free of charge, and there is no extra fee for the enterprise edition, we make our very
best work available to everyone on the same Free terms.

Ubuntu includes the very best in translations and accessibility infrastructure that the Free Software community
has to offer, to make Ubuntu usable by as many people as possible.

Ubuntu is shipped in stable and regular release cycles; a new release will be shipped every six months. You
can use the current stable release or the current development release. A release will be supported for 18
months.

Ubuntu is entirely committed to the principles of open source software development; we encourage people to
use open source software, improve it and pass it on.

Ubuntu is suitable for both desktop and server use. The current Ubuntu release supports Intel x86 (IBM-compatible
PC), AMD64 (Hammer) and PowerPC (Apple iBook and Powerbook, G4 and G5) architectures.

Ubuntu includes more than 1000 pieces of software, starting with the Linux kernel version 3.2 and GNOME 3.4, and
covering every standard desktop application from word processing and spreadsheet applications to internet access
applications, web server software, email software, programming languages and tools and of course several games.

Implementation details:
Installation of Ubuntu 12.04 Precise Pangolin:
These instructions apply for Ubuntu 12.04 and may cause serious damage to other versions.
Ubuntu 12.04 Precise Pangolin came out on April the 26th. It features an improved version of Unity, the new Heads-Up
Display (HUD), and version support for the next five years. It is completely free to download and install and offers a
fast, free, and secure alternative to Windows or OS X.

Warnings:

When choosing how to install, some options will completely erase your drive before doing so. Please read carefully
the description of your options below before choosing an install method. If you are comfortable managing partitions,
we recommend doing so manually.

Downloading:

You can Download Ubuntu 12.04 directly. The file size is just under a Gigabyte and may take anything from a few
minutes to a few hours, depending primarily on your connection speed. Downloads will be faster after the first day of
release (as less people download).

32 or 64 Bit

A good general rule of thumb is if your computer has 4GB of RAM or more, go for 64bit. Less, go for 32bit.
Basically, 64bit is faster.

CD, DVD or USB:

To install Ubuntu, you must first put the installation image onto some form of media. Your choices are CD, DVD or
USB. Most computers can boot from both, unless they lack a disc drive, in which case you can skip the next
paragraph, as youll be using a USB then.
CDs and DVDs offer no real advantage over one another, DVDs may be larger, but the space will not be used, but cost
only a tiny amount more. RW means you can write new data again and again, whereas R means once the Ubuntu
installation image is on there, there it will stay. It can be used again, but never written to again. As for + or -, + means a
computer can treat it like a USB drive, whereas is a little older and wont. Either + or -, and R or RW will work for this.
USB sticks need to be at least 2GB in size, and be prepared for it to be formatted (everything deleted).

Installing Ubuntu 12.04 Precise Pangolin:

Once youve put the image you downloaded onto a CD, DVD, or USB, you will need to shut down your computer.

Turn your computer back on, tapping F12 to select a boot device when your screen shows the name of the
manufacturer. You can then use the arrow keys, finally hitting enter, to select either USB or Disc Drive.
Once Ubuntu has booted, you will be presented with a screen that looks like this:

Click Install Ubuntu to install.

If you dont want to install all updates while installing, then you can leave the relevant box(es) unchecked.
If you dont have at least 4.5GB of available drive space, then you cant continue. If youre not plugged in, then plug in
before continuing. If youre not connected to the internet, then youll be prompted to connect when you click continue.
You can do it now using the icon to the left of the sound menu to connect. You can continue without connecting, but
you wont be able to get updates, or any language packs you may require.

Next you get to choose how to install:

Choose either to use the whole disk, or specify partitions manually.


It may say Delete Windows and Install Ubuntu and Shrink Windows and Install Ubuntu Alongside.
Choosing to install alongside will mean you are presented with a menu with the option to choose which operating
system with the arrow keys and enter every time you turn on your computer.
After clicking continue, youll be presented with a confirmation screen, mush like this:

Click Install Now to begin installing.


Youll be asked a few more questions in a second about where you are, what your name is, and how you want your
computer set up. These are for time settings, user names, and home folders.

Where are you?

Now you get to choose your location by dropping a pin on this nifty looking map. This is to select your timezone and
apply any regional adjustments.
Keyboard Layout

Now you get to enter your name, the name you want your computer to be, your username, a password, whether or not
to log in automatically, and whether or not to encrypt your home folder (which is where documents, music, and video
folder can be found, among others).

Experiment no.1b
Aim: Execution of Basic Linux Commands
Theory:

Primary man (manual) pages.


man <command> shows all information about the command
<command> help shows the available options for that command

Secondary Books and Internet

File Handling commands

mkdir make directories


Usage: mkdir [OPTION] DIRECTORY...

eg. mkdir prabhat

ls list directory contents


Usage: ls [OPTION]... [FILE]...
eg. ls, ls l, ls prabhat

cd changes directories
Usage: cd [DIRECTORY]
eg. cd prabhat

pwd print
name of current working directory
Usage: pwd

vim Vi Improved, a programmers text editor


Usage: vim [OPTION] [file]...
eg. vim file1.txt

cp copy files and directories


Usage: cp [OPTION]... SOURCE DEST
eg. cp sample.txt sample_copy.txt
cp sample_copy.txt target_dir

mv move (rename) files


Usage: mv [OPTION]... SOURCE DEST
eg. mv source.txt target_dir
mv old.txt new.txt

rm remove files or directories


Usage: rm [OPTION]... FILE...
eg. rm file1.txt , -rm rf some_dir

find search for files in a directory hierarchy


Usage: find [OPTION] [path] [pattern]
eg. find file1.txt, find -name file1.txt

history prints recently used commands


Usage: history

Pattern
A Pattern is an expression that describes a set of strings which is used to give a concise description of a set, without
having to list all elements.
eg. ab*cd matches anything that starts with ab and ends with cd etc.
ls *.txt prints all text files
Text Processing

cat concatenate files and print on the standard output

Usage: cat [OPTION] [FILE]...


eg. cat file1.txt file2.txt
cat -n file1.txt

echo display a line of text


Usage: echo [OPTION] [string] ...
eg. echo I love India

echo $HOME

grep print
lines matching a pattern
Usage: grep [OPTION] PATTERN [FILE]...
eg. grep -i apple sample.txt

wc print
the number of newlines, words, and bytes in files
Usage: wc [OPTION]... [FILE]...
eg. wc file1.txt
wc l file1.txt

sort sort lines of text files


Usage: sort [OPTION]... [FILE]...
eg. sort file1.txt
sort r file1.txt

Linux File Permissions

3 types of file permissions read, write, execute

10 bit format from 'ls l' command

2 3 4 5 6 7 8 9 10

file type owner group others


eg. drwxrw-r-- means
owner has all three permissions,
group has read and write,
others have only read permission

read permission 4, write 2, execute 1


eg. rwxrw-r--

= 764

673 = rw-rwx-wx
System Administration

chmod change file access permissions


Usage: chmod [OPTION] [MODE] [FILE]
eg. chmod 744 calculate.sh

chown change file owner and group


Usage: chown [OPTION]... OWNER[:[GROUP]] FILE...
eg. chown remo myfile.txt

su change user ID or become superuser


Usage: su [OPTION] [LOGIN]
eg. su remo, su

passwd update a users authentication tokens(s)


Usage: passwd [OPTION]
eg. passwd

who show who is logged on


Usage: who [OPTION]
eg. who , who -b, who q

ps report a snapshot of the current processes


Usage: ps [OPTION]
eg. ps, ps -el

kill to kill a process(using signal mechanism)


Usage: kill [OPTION] pid
eg. kill -9 2275

Archival

tar to archive a file


Usage: tar [OPTION] DEST SOURCE
eg. tar cvf /home/archive.tar /home/original
tar xvf /home/archive.tar

zip package and compress (archive) files


Usage: zip [OPTION] DEST SOURSE
eg. zip original.zip original

unzip list, test and extract compressed files in a ZIP archive


Usage: unzip filename
eg. unzip original.zip

Network

ssh SSH client (remote login program)


ssh is a program for logging into a remote machine and for executing commands on a remote machine
Usage: ssh [options] [user]@hostname
eg. ssh X guest@10.105.11.20

scp secure copy (remote file copy program)


scp copies files between hosts on a network
Usage: scp [options] [[user]@host1:file1] [[user]@host2:file2]
eg. scp file1.txt guest@10.105.11.20:~/Desktop/

File Systems

fdisk partition manipulator


eg. sudo fdisk -l

mount mount a file system


Usage: mount t type device dir
eg. mount /dev/sda5 /media/target

umount unmount file systems


Usage: umount [OPTIONS] dir | device...
eg. umount /media/target

du estimate file space usage


Usage: du [OPTION]... [FILE]...
eg. du

df report filesystem disk space usage

Usage: df [OPTION]... [FILE]...


eg. df

quota display disk usage and limits


Usage: quota [OPTION]

eg. quota v
Conclusion:

Experiment no. 2a
Aim -: To study and Implement Basic Linux Networking commands
Theory
Basically there are various addresses used in network configuration like ipaddress,subnetmask,default
gateways,dns etc & There are various commands can be used to setup network configuration.they are
as follows
Networking is sometimes considered to be complex, and hard to troubleshoot and manage. However, Linux provides
you with some tools to figure out exactly what's going wrong on your network, and how to fix it.
1. ping - ping command is used to find out whether the peer host/gateway is reachable.
It is used to detect whether a system is up and running in the network or not
Syntax: ping [options] <ipaddress>
e.g ping 192.168.1.1

2. finger - finger command is used to lookup information about an user. finger command will display login, username,
home directory, shell information about a particular user
3. ifconfig - The "ifconfig" command allows the operating system to setup network interfaces and allow the user to
view information about the configured network interfaces
Syntax #ifconfig <interfactname> Eg.
#ifconfig eth0
this views the configuration of interface eth0
To set up ip address following command can be
used.
Syntax: ifconfig <interfacename> <ipaddress>
<broadcast-address> up/down

netmask <subnetmaskaddress> broadcast

For example-: To Assign ip-address, netmask at the same time to interface eht0 following command can be
used.
# ifconfig eth0 192.168.2.2 netmask 255.255.255.0 broadcast 192.168.2.255 up/down

4. traceroute - print the route packets take to network host. Traceroute utilizes the IP protocol `time to live' field and
attempts to elicit an ICMP TIME_EXCEEDED response from each gateway along the path to some host
root@ubuntu:~# traceroute6 gmail.com

5. host - host is a simple utility for performing DNS lookups. It is normally used to convert names to IP addresses
and vice versa.
6. nslookup - nslookup is a network administration tool for querying the Domain Name System (DNS) to obtain
domain name or IP address mapping or any other specific DNS record. It is also used to troubleshoot DNS related
problems.
Syntax-:nslookup <domainname>
e.g. nslookup yahoo.com

7. dig - (domain information groper) is a flexible tool for interrogating DNS name servers. It performs DNS lookups
and displays the answers that are returned from the name server(s) that were queried. Most DNS administrators use
dig to troubleshoot DNS problems because of its flexibility, ease of use and clarity of output.
Syntax: dig<domain-name>
e.g dig yahoo.com

8.netstat - Netstat command displays various network related information such as network connections, routing
tables, interface statistics, masquerade connections, multicast memberships etc.,
Syntax:netstat <option>
e.g.netstat a

9. route - Route command is used to show/manipulate the IP routing table. It is primarily used to setup static routes
to specific host or networks via an interface.

1)Display Existing Routes


Syntax : $route <option>
E.g
$ route -n
Kernel IP routing table
Destination
Gateway
192.168.1.0
0.0.0.0
0.0.0.0
192.168.1.10

Genmask
255.255.255.0
0.0.0.0

Flags Metric
U
0
UG
0

Ref
0
0

0
0

Use Iface
eth0
eth0

2) Adding default gateway


Syntax -: route add default gw <ip-address> <interface>
e.g route add default gw 192.168.1.1 eth0
10. tzselect - The tzselect program asks the user for information about the current location, and outputs the
resulting time zone description to standard output. The output is suitable as a value for the TZ environment variable.

Experiment no. 2b
Aim : Assign Multiple IP address to Single LAN
Theory:
To have multiple IP address it is necessary to create alias for eth0.
To create alias for eth0 ifconfig command is used.
It is use to configure a network interface and aliases
Implementation Details:
Assuming that your eth0 IP is 192.168.1.10 and you would like to create an alias eth0:0 with IP 192.168.1.11. Type the
following command:
sudo ifconfig eth0:0 192.168.1.11 up

OR
sudo /sbin/ifconfig eth0:0 192.168.1.11 up
Verify that alias is up and running using following two command(s):
/sbin/ifconfig
ping 192.168.1.11
ping your-getway-ip

Permanent configuration

Your ethernet configuration is located in a file called /etc/network/interfaces. If you reboot system you will lost your
alias. To make it permanent you need to add it network configuration file:
gksudo gedit /etc/network/interfaces
OR
sudo vi /etc/network/interfaces
Append the following configuration:
auto eth0:0
iface eth0:0 inet static
name Ethernet alias LAN card
address 192.168.1.11
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0
Save the file and restart system or restart the network:
sudo /etc/init.d/networking restart
Please note that you can also use graphical tools located at System > Administration > Networking menu. Or use
the following GUI tool to setup aliases, hostname, dns settings etc:
sudo network-admin
If you want more network aliases, use eth0:1, eth0:2, eth0:N (max upto 254).

Experiment no. 2c
Aim: Adding Static Route in Routing table
Theory:
Static routing is the term used to refer to the manual method used to set up routing. An administrator enters routes into
the router using configuration commands. This method has the advantage of being predictable, and simple to set up. It
is easy to manage in small networks but does not scale well.
Advantages of Static Routes

Easy to configure

No routing protocol overhead

Disadvantages of Static Routes

Network changes require manual reconfiguration

Network outages cannot be automatically routed around

Does not scale well in large networks.

Implementation Details:
Add a Static route using "route" command
route add [-net|-host] <IP/Net> netmask <Mask> gw <Gateway

IP> dev <Int>X

Example
route add -net 10.10.10.0 netmask 255.255.255.0 gw 192.168.1.1 dev eth0
route add -host 10.10.1.1 netmask 255.255.255.0 gw 192.168.1.1 dev eth0
This adds the route immediatly to the Kernel IP routing table. To confirm the route has been successfully, simply
type the "route" command with no arguments:
route
Kernel IP routing table
Destination

Gateway

Genmask

192.168.1.254

localnet

Metric Ref

Use

Iface

255.255.255.0 U

eth0

255.255.255.0 U

eth0

10.10.10.0

255.255.255.0 U

eth0

10.10.1.1

255.255.255.0 U

eth0

0.0.0.0

eth0

default

192.168.1.1

Flags

UG

Use
netstat -rn
to print the Kernel IP Routing table.
To keep the Static Route persistent or you want to add the route entries to the network script files (not using the
route command) then all you need to do is to edit the file
/etc/network/interfaces
and the static routes in the following format:

up route add [-net|-host] <host/net>/<mask> gw <host/IP> dev <Interface>


For the change to /etc/network/interface to take effect. please restart the "networking" service as follows:
sudo /etc/init.d/networking restart
NOTE: If you added the route already using the "route" then there is no need to restart the networking service
because, the next time server is restarted this takes effect.

Observations:
up route add -net 172.20.11.0/16 gw 172.20.10.254 dev eth1
And the file will like the following
sudo cat /etc/network/interfaces
The output should show something like this
sudo cat /etc/network/interfaces
The output should show something like this
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0 eth1
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254
# dns-* options are implemented by the resolvconf package, if installed
iface eth1 inet static
address 172.20.10.1
netmask 255.255.255.0
broadcast 172.20.10.255
gateway 172.20.10.254
# static route
up route add -net 172.20.11.0/16 gw 172.20.10.254 dev eth1
The above has 2 Ethernet interfaces and the static route is added to the interface eth1.

Experiment no. 2d
Aim: Configure Linux Server as a Router and configure IP Forwarding
Theory:
ROUTER
The router that will be created is an Internet gateway for wired and/or wireless clients to share an internet connection
with one IP address.
The essential components are:

routing of packets from your local networks to the internet, with IP_masquerading

handling DNS requests

providing IP addresses to devices on your local networks (DHCP)

This router can also provide:

A firewall

port forwarding

IP FORWARDING
By default any modern Linux distributions will have IP Forwarding disabled. This is normally a good idea, as most
peoples will not need IP Forwarding, but if we are setting up a Linux router/gateway or maybe a VPN server (pptp or
ipsec) or just a plain dial-in server then we will need to enable forwarding.
Implementation:
Setting Up Your Network Interfaces
1. Device Naming Overview

Network
Device

Internal
Network

or

External

eth0

External

Network adapter connected to an external network (your broadband


connection)

eth1

Internal

Network adapter connected to a hub or switch

wlan0

Internal

Wireless network adapter

br0

Internal

Network bridge between eth1 and wlan0 that will treat the two like one
device

Description

2. Taking a Backup
Issue the following command to take a backup of your current network configuration:
sudo cp /etc/network/interfaces /etc/network/interfaces.bak
3. Configuring the External Network Interface

a) Setting up External Network Interface


Here, we configure the Ubuntu networking system to bring the the local loopback and external network interfaces up
by editing /etc/networking/interfaces. The primary goal here is to set up your external network interface ( eth0, or
whatever you're using in place of it) to be brought up by the networking subsystem.
For Dynamic IP Addresses (DHCP) Only
Open /etc/network/interfaces. Delete everything and paste in what is below. Follow the commented out instructions
carefully.
# Set up the local loopback interface
auto lo
iface lo inet loopback
# Set up the external interface
#
# Don't forget to change eth0 to the proper name of the external
# interface if applicable.
#
auto eth0
iface eth0 inet dhcp
For Static IP Address Only
Open /etc/network/interfaces. Delete everything and paste in what is below. Follow the commented out instructions
carefully.
# Set up the local loopback interface
auto lo
iface lo inet loopback
# Set up the External interface
#
# For every xxx.xxx.xxx.xxx, enter the numeric address given to you
# by your Internet provider. Don't forget to change eth0 to the proper
# name of the external interface if applicable.
#
auto eth0
iface eth0 inet static
address xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx
Now, set up your DNS servers as given to you by your service provider in /etc/resolv.conf, which should look
something like this
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx
b) Testing Connectivity
Reload the network configuration and test for connectivity,
sudo /etc/init.d/networking restart
ping -c 3 -W 10 ubuntu.com

4. Configuring the Internal Network Interfaces


Append the following to /etc/network/interfaces and follow the commented out instructions carefully.
# Set up the internal wired network
#
# Don't forget to change eth1 to the proper name of the internal
# wired network interface if applicable.
#
auto eth1
iface eth1 inet static
address 192.168.0.1
network 192.168.0.0
netmask 255.255.255.0
broadcast 192.168.0.255
Your internal network interface is: eth1
5. Enable IP forwarding and Masquerading
Doing the above might not be enough to make the Ubuntu machine a real router which does NAT (Network Address
Translation) and IP Forwarding. The following script configures the Kernel IPTable and IP forwarding. You will have to
configure at least the script's 2 variables; the 1st is the external network interface; the 2nd is the internal network
interface.
EXTIF="eth0"
INTIF="eth1"
echo -e "\n\nLoading simple rc.firewall-iptables version $FWVER..\n"
DEPMOD=/sbin/depmod
MODPROBE=/sbin/modprobe
EXTIF="eth0"
INTIF="eth1"
#INTIF2="eth0"
echo " External Interface: $EXTIF"
echo " Internal Interface: $INTIF"
#======================================================================
#== No editing beyond this line is required for initial MASQ testing ==
echo -en " loading modules: "
echo " - Verifying that all kernel modules are ok"
$DEPMOD -a
echo "----------------------------------------------------------------------"
echo -en "ip_tables, "
$MODPROBE ip_tables
echo -en "nf_conntrack, "
$MODPROBE nf_conntrack
echo -en "nf_conntrack_ftp, "
$MODPROBE nf_conntrack_ftp
echo -en "nf_conntrack_irc, "
$MODPROBE nf_conntrack_irc
echo -en "iptable_nat, "
$MODPROBE iptable_nat
echo -en "nf_nat_ftp, "
$MODPROBE nf_nat_ftp
echo "----------------------------------------------------------------------"
echo -e " Done loading modules.\n"
echo " Enabling forwarding.."
echo "1" > /proc/sys/net/ipv4/ip_forward
echo " Enabling DynamicAddr.."

echo "1" > /proc/sys/net/ipv4/ip_dynaddr


echo " Clearing any existing rules and setting default policy.."
iptables-restore <<-EOF
*nat
-A POSTROUTING -o "$EXTIF" -j MASQUERADE
COMMIT
*filter
:INPUT ACCEPT [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
-A FORWARD -i "$EXTIF" -o "$INTIF" -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
-A FORWARD -i "$INTIF" -o "$EXTIF" -j ACCEPT
-A FORWARD -j LOG
COMMIT
EOF
echo -e "\nrc.firewall-iptables v$FWVER done.\n"
After configuring the 2 variables, save the script below as nat.sh and make it executable by doing
chmod a+x nat.sh
Now, test the script by running as root
sudo sh nat.sh
To test ping Google public DNS from the console.
ping -c 3 -W 10 8.8.8.8
If ping responds, make our new script bootable so we don't have to run the script every time we restart.
sudo cp nat.sh /etc/init.d/
sudo ln -s /etc/init.d/nat.sh /etc/rc2.d/S95masquradescript
As a final test, restart your computer and test to see if you still have the same functionality.

Observation:
Configuration of Ubuntu Router External Network Interface
PING ubuntu.com (82.211.81.166) 56(84) bytes of data.
64 bytes from signey.ubuntu.com (82.211.81.166): icmp_seq=1 ttl=43 time=99.9 ms
64 bytes from signey.ubuntu.com (82.211.81.166): icmp_seq=2 ttl=43 time=109 ms
64 bytes from signey.ubuntu.com (82.211.81.166): icmp_seq=3 ttl=43 time=100 ms
--- ubuntu.com ping statistics --3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 99.982/103.450/109.419/4.254 ms

Conclusion:

Experiment no. 3
Aim -: To study and Implement Configuration of Linux as FTP and Web server
Theory
The steps to configure FTP and Web server on Ubuntu linux server is as follows
A] Configuration of FTP server on Ubuntu
FTP is designed to transfer large file across a network from one system to another.Like most internet operation,
FTP works on a client/server model.FTP client program can enable users to transfer files to and from a remote
system running an FTP server program
To configure FTP server following configurations can be used as follows
Configuration file : /etc/vsftpd/vsftpd.conf
Daemon : /usr/sbin/vsftpd
Service : service vsftpd restart

FTP SERVER SIDE Configuration


1) First check whether FTP Packages were installed or not by using rpm q command
#rpm q vsftpd
If its not installed then install it by using yum install or rpm I command
#rpm i vsftpd
Or
# yum install vsftpd
2) Open vsftpd.conf configuration file using vi or any editor and change following lines of configuration
file
Anonymous enable=YES/NO
Which is used to allow anonymous users to use FTP
SERVER Local enable=YES/NO
Which is used to allow local users to use FTP SERVER
write enable=YES/NO
Which allows user to Upload the file or modify the contents of server directory
3)Once configuration is done Restart service using following command
#service vsftpd restart

FTP CLIENT SIDE Configuration


At client side login to FTP server using ipaddress of server like
$ftp 172.16.0.1
After login to ftp server by assigining userneme and password ftp prompt will be displayed as
ftp>
here we can use following commands to upload or download files from ftp server
ftp>ls

shows listing of files and directories on server.


ftp>get <filename>
used to download file from server
ftp>put <filename>
used to upload file on server
B] Configuration of Apache Web server on Ubuntu
The Apache Web server is a free HTTP (Web) server developed by the Apache Server Project. It is a
reliable, efficient , and easily extensible Web Server it required following configurations

Packages
-httpd
Configurations file - /etc/httpd/conf/httpd.conf
Daemons
- httpd

Implementation Details:
/etc/httpd/conf/httpd.conf Main server configuration file
/var/www/html web server document directory
Steps to install and configure HTTP server
1. Installing the Apache package:
sudo apt-get install apache2
2. Starting, Stopping and Restarting Apache:
sudo /etc/init.d/apache2 start
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 restart
3. Modify the /etc/apache2/apache2.conf
Modify SererverName Directive
Change the default value for ServerName www. <kjsce.com>
ServerName domain name (IP of the server or DNS of the server)
DocumentRoot Directive
Put the website content in /var/www/
4. Test from the client:Open browser and type URL of server or the IP Address of the server if the DNS is not
configured.
Virtual Hosting
IP Based Virtual Hosting
1. Assigning multiple IP addresses to single Ethernet Interface
ifconfig eth0:0 10.10.10.1 netmask 255.0.0.0 up
2. Check the ipaddress:
ifconfig
3. Create two new folders in the /var/www directory named as site1 and site2
cd /var/www/html
# mkdir site1
# mkdir site2
4. Create some sample HTML files say index.html in each of the folders using the nano editor:
/var/www/site1># nano index.html
index.html
<html>
This is Site 1..
</html>
/var/www/site2># nano index.html
index.html
<html>
This is Site 2..
</html>
5. Add the VirtualHost Directive to the apache2.conf file
/etc/apache2> nano apache2.conf
Add the following commands:
<VirtualHost 172.17.14.22>
DocumentRoot /home/www/site1

</VirtualHost >
<VirtualHost 10.10.10.1>
DocumentRoot /home/www/site2
</VirtualHost >
6. Test from the client
Open browser and type URL of servers
http:// 172.17.14.22
You will get a page of first web site (index.html in site1)
This is Site1..
http:// 10.10.10.1
You will get a page of second web site (index.html in site2)
This is Site2..
Conclusion:

Experiment no. 4
Aim -: To study and Implement Configuration of Linux as DNS Server
Theory
DNS server locates and translates domain names into corresponding associated IP
addresses and vice versa. In linux DNS Server is called as BIND server. Its requirement
is as follows
Required Packages
-bind, bind-utils,caching-nameserver
Configuration files -etc/named/named.conf
-/var/named/named.local
service
-service named restart
A] Server side Configuration
1) Install following packages using rpm command
#rpm ivh bind
# rpm ivh Caching-nameserver
#rpm ivh bind-utils
2) Open named.conf configuration file
# vi /etc/named.conf
In that file copy/paste forword lookup zones and replace localhost with kjsce.edu as well as specify name of
file as kjsce.for
zone "kjsce.edu" IN {
type master;
file "kjsce.for";
allow-update { none; };
};
Simillarly copy/paste reverse lookup zones and replace 0.0.127 with your servers network address in reverse
order as well as specify name of file as kjsce.rev
zone "1.168.192.in-addr.arpa" IN {
type master;
file "kjsce.rev";
allow-update { none; };
};
Then save this file
3) now create kjsce.for and kjsce.rev files by copying and renaming named .local file as follows
#cp /var/named/named.local /var/named/kjsce.for
##cp /var/named/named.local /var/named/kjsce.rev

4)Now open kjsce.for file in vi editor and in that file replace all localhost with Server.kjsce.edu and at the end of
file add two lines & save that file
Server.kjsce.edu

IN

192.168.1.1

www

IN

CNAME Server.kjsce.edu

5)Simillarly open kjsce.rev file in vi editor and in that file also replace all localhost with Server.kjsce.edu and at
the end of file just change PTR value if needed.PTR value is last number of your network segment so here we
have 1 so dont change it & save that file
1

IN
PTR
Server.kjsce.edu

6) now
service

restart

*#service
restart

named

named

B] Client side Configuration


At client side open terminal and try to ping server.kjsce.edu if it gives reply means our server is working fine
otherwise check configuration again
Conclusion

Experiment no. 5
Aim -: To study and Implement Configuration of Linux as a Firewall
Theory
A firewall is a set of related programs, located at a network gateway server that protects the resources of a
private network from users from other networks.In linux iptables is the user- space tool for configuring firewall
rules in the Linux kernel. ipset is an extension to iptables that allows you to create firewall rules that match entire
"sets" of addresses at once.

Packet Processing In iptables


All packets inspected by iptables pass through a sequence of built-in tables (queues) for processing. Each of these
queues is dedicated to a particular type of packet activity and is controlled by an associated packet
transformation/filtering chain.
There are three tables in total. The first is the mangle table which is responsible for the alteration of quality of service
bits in the TCP header. This is hardly used in a home or SOHO environment.
The second table is the filter queue which is responsible for packet filtering. It has three built-in chains in which you
can place your firewall policy rules. These are the:

Forward chain: Filters packets to servers protected by the firewall.


Input chain: Filters packets destined for the firewall.
Output chain: Filters packets originating from the firewall.

The third table is the nat queue which is responsible for network address translation. It has two built-in chains; these
are:

Pre-routing chain: NATs packets when the destination address of the packet needs to be changed.
Post-routing chain: NATs packets when the source address of the packet needs to be changed.

Important Iptables Command Switch Operations


Each line of an iptables script not only has a jump, but they also have a number of command line options that are used
to append rules to chains that match your defined packet characteristics, such the source IP address and TCP port.
There are also options that can be used to just clear a chain so you can start all over again. Tables 14.2 through 14.6
list the most common options.

a. Table 14-2 General Iptables Match Criteria


iptables command
Switch

Desciption

-t <-table->

If you don't specify a table, then the filter table is assumed. As discussed before, the possible
built-in tables include: filter, nat, mangle

-j <target>

Jump to the specified target chain when the packet matches the current rule.

-A

Append rule to end of a chain

-F

Flush. Deletes all the rules in the selected table

-p <protocol-type>

Match protocol. Types include, icmp, tcp, udp, and all

-s <ip-address>

Match source IP address

-d <ip-address>

Match destination IP address

-i <interface-name>

Match "input" interface on which the packet enters.

-o <interface-name>

Match "output" interface on which the packet exits

iptables -A INPUT -s 0/0 -i eth0 -d 192.168.1.1 -p TCP -j ACCEPT


iptables is being configured to allow the firewall to accept TCP packets coming in on interface eth0 from any IP
address destined for the firewall's IP address of 192.168.1.1. The 0/0 representation of an IP address means any.
iptables -A FORWARD -s 0/0 -i eth0 -d 192.168.1.58 -o eth1 -p TCP \
--sport 1024:65535 --dport 80 -j ACCEPT
iptables is being configured to allow the firewall to accept TCP packets for routing when they enter on interface eth0
from any IP address and are destined for an IP address of 192.168.1.58 that is reachable via interface eth1. The
source port is in the range 1024 to 65535 and the destination port is port 80 (www/http).
iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT
iptables is being configured to allow the firewall to send ICMP echo-requests (pings) and in turn, accept the expected
ICMP echo-replies.
iptables is being configured to allow the firewall to send ICMP echo-requests (pings) and in turn, accept the expected
ICMP echo-replies.
[root@bigboy tmp]# iptables-save > /etc/sysconfig/iptables
The iptables-save command outputs the content of your configuration to your screen or STOUT. By redirecting this
output to a file, you can later use the iptables-restore command to use this data and revert iptables to the original
configuration when the iptables-save command was run.
In linux firewall can be configured using iptable command as follows
Syntax of iptable command

1) iptables L -> View the current firewall configuration


2) cat /etc/sysconfig/iptables-> View/read the real firewall file
So edit this file to configure firewall as follows
3)$vi /etc/sysconfig/iptables Edit and Save the firewall iptables file which look like as follows

After configuring this file restart the server using following command to take effect
Shutdown r now
Conclusion

Experiment no. 6
Aim: IT Infrastructure monitoring using NAGIOS
Theory:
Nagios
Nagios is an open source computer system monitor, network monitoring and infrastructure onitoring software
application. Nagios offers monitoring and alerting for servers, switches, applications, and services. It
watches hosts and services. It alerts users when things go wrong and alerts them again when those wrong things get
better/resolved.
Nagios was originally designed to run under Linux, but also runs well on other Unix variants.
Nagios is Open Source Software licensed under the GNU GPL V2.
Nagios Agents
i.

1. NRPE
Nagios Remote Plugin Executor (NRPE) is a Nagios agent that allows remote systems monitoring using
scripts that are hosted on the remote systems. It allows for monitoring resources such as disk usage, system load or
number of users currently logged in. Nagios periodically polls the agent on the remote system using
the check_nrpe plugin.

ii.

2. NRDP
Nagios Remote Data Processor (NDRP) is a Nagios agent with a flexible data transport mechanism and
processor. It is designed with an architecture that allows it to be easily extended and customized. NRDP uses
standard ports and protocols (HTTP(S) and XML) and can be implemented as a replacement for NSCA.

iii.

3. NSClient++
This program is mainly used to monitor Windows machines. Being installed on a remote system NSClient++
listens to port TCP 1248. Nagios plugin that is used to collect information from this addon is called check_nt. As
NRPE, NSClient++ allows to monitor the so called "private services" (memory usage, CPU load, disk usage, running
processes, etc.)
Implementation Details:
Required Packages
Make sure you've installed the following packages on your Ubuntu installation before continuing.

Apache 2
PHP
GCC compiler and development libraries
GD development libraries

You can use apt-get to install these packages by running the following commands:
sudo apt-get install apache2
sudo apt-get install libapache2-mod-php5
sudo apt-get install build-essential

With Ubuntu 6.10, install the gd2 library with this command:
sudo apt-get install libgd2-dev

With Ubuntu 7.10, the gd2 library name has changed, so you'll need to use the following:
sudo apt-get install libgd2-xpm-dev

1) Create Account Information


Become the root user.
sudo -s
Create a new nagios user account and give it a password.
/usr/sbin/useradd -m -s /bin/bash nagios
passwd nagios
On older Ubuntu server editions (6.01 and earlier), you will need to also add a nagios group (it's not created by
default). You should be able to skip this step on desktop, or newer server editions of Ubuntu.
/usr/sbin/groupadd nagios
/usr/sbin/usermod -G nagios nagios
Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the
nagios user and the apache user to the group.
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd www-data

2) Download Nagios and the Plugins


Create a directory for storing the downloads.
mkdir ~/downloads
cd ~/downloads
Download the source code tarballs of both Nagios and the Nagios plugins
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz
3) Compile and Install Nagios
Extract the Nagios source code tarball.
cd ~/downloads
tar xzf nagios-3.2.3.tar.gz
cd nagios-3.2.3

Run the Nagios configure script, passing the name of the group you created earlier like so:
./configure --with-command-group=nagcmd

Compile the Nagios source code.


make all

Install binaries, init script, sample config files and set permissions on the external command directory.
make install
make install-init
make install-config
make install-commandmode

Don't start Nagios yet - there's still more that needs to be done...
4) Customize Configuration
Sample configuration files have now been installed in the /usr/local/nagios/etc directory. These sample files should
work fine for getting started with Nagios. You'll need to make just one change before you proceed...
Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address
associated with the nagiosadmin contact definition to the address you'd like to use for receiving alerts.

vi /usr/local/nagios/etc/objects/contacts.cfg

5) Configure the Web Interface


Install the Nagios web config file in the Apache conf.d directory.
make install-webconf

Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this
account - you'll need it later.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Restart Apache to make the new settings take effect.


/etc/init.d/apache2 reload

Note: Consider implementing the ehanced CGI security measures described here to ensure that your web
authentication credentials are not compromised.
6) Compile and Install the Nagios Plugins
Extract the Nagios plugins source code tarball.
cd ~/downloads
tar xzf nagios-plugins-1.4.11.tar.gz
cd nagios-plugins-1.4.11

Compile and install the plugins.


./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

7) Start Nagios
Configure Nagios to automatically start when the system boots.
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

Verify the sample Nagios configuration files.


/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If there are no errors, start Nagios.
/etc/init.d/nagios start

8) Login to the Web Interface


You should now be able to access the Nagios web interface at the URL below. You'll be prompted for the username
(nagiosadmin) and password you specified earlier.
http://localhost/nagios/

Click on the "Service Detail" navbar link to see details of what's being monitored on your local machine. It will take a
few minutes for Nagios to check all the services associated with your machine, as the checks are spread out over
time.
9) Other Modifications
If you want to receive email notifications for Nagios alerts, you need to install the mailx (Postfix) package.
sudo apt-get install mailx
sudo apt-get install postfix

You'll have to edit the Nagios email notification commands found in /usr/local/nagios/etc/objects/commands.cfg and
change any '/bin/mail' references to '/usr/bin/mail'. Once you do that you'll need to restart Nagios to make the
configuration changes live.
sudo /etc/init.d/nagios restart

Configuring email notifications is outside the scope of this documentation. Refer to your system documentation,
search the web, or look to the Nagios Support Portal or Nagios Community Wiki for specific instructions on configuring
your Ubuntu system to send email messages to external addresses.

Always make sure you verify your configuration before you (re)start Nagios.
Starting Nagios
1. Init Script: The easiest way to start the Nagios daemon is by using the init script like so:
/etc/rc.d/init.d/nagios start
2. Manually: You can start the Nagios daemon manually with the -d command line option like so:
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg

Restarting Nagios
Restarting/reloading is nececessary when you modify your configuration files and want those changes to take effect.
1. Init Script: The easiest way to restart the Nagios daemon is by using the init script like
/etc/rc.d/init.d/nagios reload
2. Web Interface: You can restart the Nagios through the web interface by clicking the "Process Info" navigation
link and selecting "Restart the Nagios process":

3. Manually: You can restart the Nagios process by sending it a SIGHUP signal like so:
kill -HUP <nagios_pid>

Stopping Nagios
1. Init Script: The easiest way to stop the Nagios daemon is by using the init script like so:
/etc/rc.d/init.d/nagios stop

2. Web Interface: You can stop the Nagios through the web interface by clicking the
"Process Info" navigation link and selecting "Shutdown the Nagios process":

3. Manually: You can stop the Nagios process by sending it a SIGTERM signal like so:
kill <nagios_pid>
Observation:

Conclusion:

Experiment no. 7
Aim: Virtualization on Linux

Theory:
Virtualization
Virtualization allows an unmodified operating system with all of its installed software to run in a special environment,
on top of your existing operating system.
Host operating system (host OS) - This is the operating system of the physical computer on which VirtualBox was
installed.
Guest operating system (guest OS) - This is the operating system that is running inside the virtual machine.
Virtual machine (VM) - This is the special environment that VirtualBox creates for your guest operating system while it
is running. In other words, you run your guest operating system "in" a VM. Normally, a VM will be shown as a window
on your computer's desktop
Oracle virtualbox
Oracle virtualbox is a cross-platform virtualization software which means it can be installed on windows, Mac and
Linux. VirtualBox supports all major operating systems in its virtual machines. Guest OS can be of Windows family,
Linux family, Mac OS X, Unices, Solaris and Others.
Implementation Details:
First, install Virtual Box on Ubuntu.
Then, configure Windows XP as a Virtual Machine on Ubuntu using VirtualBox.
i. Steps to install Virtualbox on ubuntu 12.04
Installing virtualbox on ubuntu 12.04 is very simple, just with 4 commands. Lets start
1. Type the below command to add virtualbox repository.
krizna@leela:~$ sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib"
>> /etc/apt/sources.list'
2. Download and register oracle public key by issuing the below command
krizna@leela:~$ wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add 3. Now update the repositories.
krizna@leela:~$ sudo apt-get update
4. After updating repositories, start installing Virtualbox 4.2.
krizna@leela:~$ sudo apt-get install virtualbox-4.2
Installation will take some time to download and install virtualbox and other dependencies.

Using VirtualBox configure Windows XP as a Virtual Machine on Ubuntu.


1. After installation, just type sudo virtualbox to open Oracle VM VirtualBox manger.

2. Click New. Now type name of your virtual machine and choose the OS type as Microsoft Windows
and version as Windows XP (For installing Windows XP).

3. Recommended
Memory (RAM) size will be allocated automatically based on OS type. (You can increase/decrease Memory by
adjusting the slider, but keep within the green). Choose Create a virtual hard drive now option and click
Create.

4. In the Next screen, choose location to store virtual


machine by clicking the folder icon in the right side.
Choose file size (if you want to install more programs in the virtual machine increase the size accordingly). Now

choose Hard disk file type as VDI (VirtualBox Disk image) and Fixed size for Storage on physical hard
drive ( Fixed size will increase Virtual machine performance ). Now click Create.

Now virtual machine has


been successfully created
just like assembling the hardware for a physical machine. Now we need to install OS (Windows XP).
5. Select the virtual machine and click Settings.

6. Click Storage Tab and Click Empty under the IDE Controller. Now you can see the CD/DVD Drive under the
Attributes column. Now click the CD icon and choose the downloaded Windows XP iso file.

7. Another option is to
download pre installed
OS VirtualBox images
as

VDI

files

for

completely free. Each VirtualBox image saves your installation and configuration time. Its not required to get CD
or ISO and install on VirtualBox. Just Download these Free VDI (VB hard disk files) and start using them.

8. Select the virtual machine you want to use, and click the Start button. Click OK for all messages and warnings.

Observation:

You will notice XP is inside of a window. Within that window is a menu with three choices. One of those menus you will
use quite often is the Machine menu.

Conclusion:

Experiment no. 8
Aim: To Study Structure of LaTeX document.
Theory:
I. Introduction
LaTeX is a macro package that enables authors to typeset and print their work at the highest typographical
quality, using a predefined, professional layout. It uses the TeX formatter as its typesetting engine. The approach
of LaTeX is quite different from the WYSIWYG approach that most modern word processors, such as MS
Word take. When using LaTeX, it is not normally possible to see the final output while typing the text, but the
final output can be previewed on the screen after processing the file.
Advantages of LaTeX:
1. Ready-made styles or templates are available so that authors need to focus only on the content.
The LaTeX system takes charge of the formatting.
2.
Easy
to
type
mathematical
equations.
3. Generates references and table of contents
automatically
II. Installation
A free LaTeX distribution is available from MikTeX (www.miktex.org) and an IDE called TeXMaker can be used as
a graphical interface. The input is written in plain text and stored as a *.tex file and the output can be generated
as either *.ps or *.pdf file.
III Basic structure of a document
The basic structure of a LaTeX document is as follows:
\documentclass[options]{style}
% Comment line
\begin{document}
Content goes here.
\end{document}
There are 4 different default document classes:
Article, Report, Letter, Book
The documentclass supports various options such as font size, page layout (single or two column), paper size (eg.
A4 paper), and various styles such as article (for papers), reports, book, slides, etc. Numerous syntax
commands are supported by the LaTeX system for professional text editing. For example, a word in bold
can be written as
\textbf{some word} which will be displayed as some word. Different chapters or sections can be started with
the syntax \section{Section Name} and its sub-sections can be written with
\chapter{name}
%only with books and reports
\section{name}
\subsection {name}.
\paragraph{name}
Line Break
\\ or \newline does a carriage return.
\\ \\ leaves a blank line without starting a new
paragraph
Page break:
\newpage
Font Style:
bold face: \textbf{some text}

italics: \textit{some text}

Author and date, abstract


In order to make a simple document header, there are commands to specify the author, title and date of the
document:
For example
\author{John Smith}
\title{A simple document}
\date{\today} \% adds the current date
IV Mathematics
Mathematics can be typeset inline within a paragraph, or the paragraph can be broken to typeset it
separately. Mathematical text within a paragraph is entered between \(and \), between $ and $, or between
\begin{math} and
\end{math}. Example:
\begin{displaymath}
\lim_{n \to \infty}
\sum_{k=1}^n \frac{1}{k^2}
= \frac{\pi^2}{6}
\end{displaymath}

will produce the output as

Some of Inbuilt Functions are as follows

V. Tables
Tables can be written using the \begin{tabular} syntax. An example is illustrated below:

Conclusion:

Вам также может понравиться