0% found this document useful (0 votes)
43 views32 pages

20-CP-09 SP Assignment 2

The document discusses configuring various networking and remote access services on Red Hat Enterprise Linux and CentOS systems. It includes configuring Squid, DHCP, firewall rules, installing Asterisk for VOIP, and setting up remote login via SSH, Telnet, RDP and VNC as well as file transfer using SCP.

Uploaded by

Salman Ahmad
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)
43 views32 pages

20-CP-09 SP Assignment 2

The document discusses configuring various networking and remote access services on Red Hat Enterprise Linux and CentOS systems. It includes configuring Squid, DHCP, firewall rules, installing Asterisk for VOIP, and setting up remote login via SSH, Telnet, RDP and VNC as well as file transfer using SCP.

Uploaded by

Salman Ahmad
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/ 32

University of Engineering & Technology,

Taxila

Faculty of Telecommunication & Information Engineering


B.Sc. Computer Engineering

System Programming
Assignment # 02

SUBMITTED TO:
Dr. Zahid Mehmood

SUBMITTED BY:
MUHAMMAD UBAID ASHRAF 20-CP-09

Semester: 8th
Questions
Question 1:
You need to configure the Squid server in the RedHat Enterprise CENTOS LINUX
platform for the following given scenarios:

Part a)
Set the hostname of your CENTOS LINUX pc as your name along with uet e.g.
aliuet.
Answer:

Part b)
Install two LAN cards in your CENTOS LINUX PC and configure one LAN card (Use
for Squid Internal Network) with any class B network of your choice and configure a
second LAN card (Use for Squid External Network) with any class A network of
your choice.
Answer:
Power off the machine, open network settings to add adapters. In our case, adapter are
already setup.
We setup first adapter as internal network which will be used as squid internal
network:
For the second adapter, we setup it as bridged which will be used as squid external
network.

After setting up, we start the squid server


Now we edit the network configuration file for the first network interface (eth0) using a
text editor using command:
Internal Network:
gedit /etc/sysconfig/network-scripts/ifcfg-enp0s8
Then for external network:
gedit /etc/sysconfig/network-scripts/ifcfg-enp0s9

Now we restart the service using command:


sudo systemctl restart network

Part c)
Verify that the Squid server is installed and running on your PC at system startup
automatically (install Squid server if it is not installed after querying at RedHat
Enterprise LINUX platforms).
Answer:
Install squid server:
Then verify if it’s running:

Part d)
Add Squid Server port in LINUX Firewall.
Answer:

Part e)
Configure the squid server so that it can share the internet on clients' computers
according to the requirements of part b of Q1.
Answer:
Edit the squid configuration file:
gedit /etc/squid/squid.conf
There we add, acl internal_network src 172.16.0.0/24

And also allow httpp_access for internal network


Then, we create a blocklist.txt fle and add websites to it:

Then we create some rules for our squid server in the confguration fle:
Setting up the proxy on port 3128, we get access to the sites and the blocked sites are
blocked:

Question 3:
Deploy an Asterisk voice-over IP (VOIP) server that provides a calling feature
between two IP softphone clients. (10)
Answer:
Following are the steps to install Asterisk Server on Centos7:
Step 1: Installing necessary packages:
Command:
yum install gcc gcc-c++ php-xml php php-my php-pear php-mbstring
mariadb-devel mariadb-server mariadb ite-devel lynx bison gmime-devel psmisc
tftp-server httpd make ncurses-devel libtermcap-devel sendmail sendmail-cf caching-
nameserver sox newt-devel libxml2-devel libtiff-devel audiofile-devel gtk2-devel
uuid-
devel libtool libuuid-devel subversion kernel-devel kernel-devel-$(uname -r) git
subversion kernel-devel php-process crontabs cronie cronie-anacron wget vim
Output:
Step 2. Installing jansson library
Jansson package is not available with yum utility so we need to download its zip file
manually
from digip.org website.
Command:
wget http://www.digip.org/jansson/releases/jansson-2.7.tar.gz
Output:
Step 3. Extracting Jansson Package
Command:
tar -zxvf jansson-2.7.tar.gz
Output:
Step 4. Change directory and Configure the Jansson package
Command: cd jansson-2.7/
Command: ./configure –prefix=/usr
Output:
Step 5. Make Jansson
Command: make
Output:
Command: make && make install
Command: ldconfig
Output:

Step 6. Installing Asterisk 13.5.0


Command: cd
Command: wget
https://downloads.asterisk.org/pub/telephony/asterisk/oldreleases/asterisk-
13.5.0.tar.gz
Output:
Step 7. Extracting Asterisk Package
Command: tar -zxvf asterisk-13.5.0.tar.gz
Output:
Command: cd asterisk-13.5.0
Command: ./configure --libdir=/usr/lib64
Output:
Step 8. Loading mp3 Libraries
Command: contrib/scripts/get_mp3_source.sh
Output:
Step 9 Modules Installation
Command: make
Output:
Question 2:
Configure the DHCP server in RedHat Enterprise CENTOS LINUX platform on the first LAN card
(i.e., internal network of squid server) so that all clients can obtain IP address, default mask,
default gateway,and preferred DNS, and alternate DNS server settings from this DHCP server.
(10)
Answer:
Installed DHCP Server Package:
First, I installed the DHCP package on my CentOS system. I did this by running the command:
sudo yum install dhcp
Configured DHCP Server:
Next, I configured the DHCP server by editing the main configuration file. I opened the file
/etc/dhcp/dhcpd.conf using my favorite text editor:
sudo nano /etc/dhcp/dhcpd.conf
Edited the Configuration File:
Inside the dhcpd.conf file, I defined the DHCP settings. I used a basic example configuration like
this:
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.50 192.168.1.100;
option subnet-mask 255.255.255.0;
option routers 192.168.1.1;
option domain-name-servers 8.8.8.8, 8.8.4.4;
}
I adjusted the subnet, range, subnet mask, routers (default gateway), and domain name servers
(DNS) according to my network setup.
Started and Enabled DHCP Service:
After configuring the DHCP server, I saved and closed the file. Then, I started and enabled the
DHCP service to ensure it starts automatically on boot:
sudo systemctl start dhcpd
sudo systemctl enable dhcpd
Verified DHCP Service:
To ensure the DHCP service was running without any errors, I checked its status:

sudo systemctl status dhcpd


Checked DHCP Logs (Optional):
If I encountered any issues, I could check the DHCP server logs for troubleshooting:

sudo journalctl -xe


Configured Firewall (if needed):
If a firewall was enabled, I made sure to allow DHCP traffic. I added a rule to allow UDP traffic
on port 67:
sudo firewall-cmd --add-port=67/udp --permanent
sudo firewall-cmd --reload
Q4. You are required to setup remote login features via terminal on Microsoft Windows and
LINUX platforms via telnet, rdesktop, VNC server/client, and ssh/putty. (10)
Answer:
Windows Platform:
Telnet:
Telnet is a built-in feature in Windows. You can enable it by going to Control Panel > Programs >
Turn Windows features on or off. Check the box for Telnet Client and click OK.
Once enabled, you can use the telnet command in Command Prompt to connect to remote
hosts.
RDP (Remote Desktop Protocol):
Windows has Remote Desktop built-in. To enable it, go to Control Panel > System and Security >
System > Remote settings. Check the option "Allow remote connections to this computer".
Now, you can use Remote Desktop Connection (mstsc.exe) to connect to this Windows machine
remotely.
Linux Platform:
Telnet:
Install the telnet server package on your Linux machine. For example, on Ubuntu, you can do
this by running:

sudo apt-get install telnetd


Once installed, the Telnet service will start automatically. You can use the telnet command from
other machines to connect to this Linux server.
SSH (Secure Shell):
SSH is a secure alternative to Telnet and is widely used for remote access to Linux machines.
If SSH is not already installed, you can install it using your package manager. For example, on
Ubuntu, run:

sudo apt-get install openssh-server


Once installed, SSH should start automatically. You can connect to the Linux machine using an
SSH client like PuTTY (on Windows) or the ssh command on other Linux machines.
VNC (Virtual Network Computing):
Install a VNC server on your Linux machine. Popular choices include TigerVNC, TightVNC, and
RealVNC.
Install the VNC server package using your package manager. For example, on Ubuntu, you can
install TigerVNC with:
sudo apt-get install tigervnc-server
Configure the VNC server by setting up a password and other options as needed.
Start the VNC server service. The command may vary depending on the server you installed. For
TigerVNC, you can start it with:
vncserver
Once the server is running, you can use a VNC client (such as RealVNC Viewer) from other
machines to connect to your Linux machine.
Windows and Linux:
RDP (Windows) to SSH (Linux):
You can use a Windows machine with Remote Desktop Connection (RDP) to connect to a Linux
machine running an SSH server.
Ensure that the SSH server is installed and running on the Linux machine.
Use an RDP client (such as Remote Desktop Connection on Windows) to connect to the
Windows machine, and then use an SSH client (such as PuTTY) from the Windows machine to
connect to the Linux machine.
That's it! You've now set up remote login features via terminal on both Microsoft Windows and
Linux platforms using telnet, RDP, VNC, and SSH/putty protocols.
Q5. You are required to setup remote file transfer features via terminal between LINUX PCs
via SCP
script. (10)
Answer:
Install OpenSSH Server:
Ensure that OpenSSH server is installed on the Linux PCs. This is usually pre-installed on many
Linux distributions, but if it's not, you can install it using your package manager. For example, on
Ubuntu, you can run:

sudo apt-get install openssh-server


Configure SSH:
Once OpenSSH server is installed, you may want to adjust its configuration for security or
specific settings. The main configuration file is usually located at /etc/ssh/sshd_config. Make any
necessary changes and restart the SSH service for the changes to take effect.
Generate SSH Keys (Optional but Recommended):
To avoid entering passwords every time you transfer files, you can set up SSH key-based
authentication between the Linux PCs.
On the sending Linux PC, generate an SSH key pair using the command:

ssh-keygen
Follow the prompts and keep the default options. This will create a public key (id_rsa.pub) and a
private key (id_rsa) in the ~/.ssh directory.
Copy the public key to the receiving Linux PC using the ssh-copy-id command:
ssh-copy-id username@remote_host
You'll be prompted to enter the password for the remote host. Once done, SSH key-based
authentication will be set up.
Transfer Files Using SCP:
With SSH and SCP set up, you can now transfer files securely between the Linux PCs using the
SCP command. The basic syntax for SCP is:
scp /path/to/local/file username@remote_host:/path/to/destination
Replace /path/to/local/file with the path to the file you want to transfer.
Replace username with the username on the remote Linux PC.
Replace remote_host with the IP address or hostname of the remote Linux PC.
Replace /path/to/destination with the path where you want to save the file on the remote Linux
PC.
Example of Using SCP in a Script:
You can create a script to automate file transfers using SCP. For example, create a file named
transfer_files.sh and add the following content:

#!/bin/

# Define variables
local_file="/path/to/local/file"
remote_username="username"
remote_host="remote_host"
remote_destination="/path/to/destination"

# Transfer file using SCP


scp "$local_file" "$remote_username"@"$remote_host":"$remote_destination"
Replace /path/to/local/file, username, remote_host, and /path/to/destination with appropriate
values.
Make the script executable using the command:
chmod +x transfer_files.sh
You can then run the script to transfer files between the Linux PCs.
Q6. You are required to setup a file server that provides a file-sharing facility between
Microsoft
Windows and Redhat Enterprise LINUX platforms. (10)
a) Create five user accounts and five folders in the Centos LINUX platform and add these five
user
accounts to the Samba server
b) The Samba server's first user account is only allowed to read data from the first folder.
c) The Samba server's second user account is allowed to read and write data from all five
folders.
d) Samba server third user account is only allowed to read and write data in folder no. three
and four.
e) The Samba server's fourth user account is only allowed to read and write data in folders no.
one and
three.
f) Samba server fifth user account is only allowed to read and write data in folder no. fourth
and fifth.
g) Add Samba server PC as a member of the Microsoft active directory.
Answer:
a) Create User Accounts and Folders:

User Accounts:
Create five user accounts on the CentOS Linux platform using the useradd command. For
example:

sudo useradd user1


sudo useradd user2
sudo useradd user3
sudo useradd user4
sudo useradd user5
Set passwords for each user using the passwd command:
sudo passwd user1
sudo passwd user2
sudo passwd user3
sudo passwd user4
sudo passwd user5
Folders:
Create five folders on the CentOS Linux platform for file sharing. For example:

sudo mkdir /shared_folder1


sudo mkdir /shared_folder2
sudo mkdir /shared_folder3
sudo mkdir /shared_folder4
sudo mkdir /shared_folder5
b) - g) Configure Samba Server:

Install Samba:
Install Samba on the CentOS Linux platform using the package manager. For example, on
CentOS, you can run:

sudo yum install samba


Edit Samba Configuration:
Edit the Samba configuration file /etc/samba/smb.conf using a text editor:

sudo nano /etc/samba/smb.conf


Add User Accounts to Samba:
Inside the [global] section of the smb.conf file, add the following lines to synchronize Linux
users with Samba users:

unix password sync = yes


passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n
*password\supdated\ssuccessfully* .
Create Samba Users:
Add the Linux user accounts to Samba using the smbpasswd command. For example:

sudo smbpasswd -a user1


sudo smbpasswd -a user2
sudo smbpasswd -a user3
sudo smbpasswd -a user4
sudo smbpasswd -a user5
Configure Share Access:
Configure share access for each user account according to the requirements specified.
You can set access permissions for each folder in the section of the smb.conf file using the valid
users, read only, and writable directives.
Join Samba Server to Active Directory:
Install the necessary packages to enable integration with Active Directory. For example, on
CentOS, you may need to install realmd and samba-winbind.
Join the Samba server to the Active Directory domain using the realm command. For example:

sudo realm join [email protected] example.com


Restart Samba Service:
After making changes to the smb.conf file, restart the Samba service for the changes to take
effect:
sudo systemctl restart smb
sudo systemctl restart nmb
Create Samba Users (Continued):
After adding the Linux user accounts to Samba using the smbpasswd command, proceed to set
up specific access permissions for each user account according to the requirements specified.
Configure Share Access (Continued):
In the section of the smb.conf file, set up access permissions as follows:

path = /shared_folder1
valid users = user1
read only = yes

[share2]
path = /shared_folder2
valid users = user2
read only = no

[share3]
path = /shared_folder3
valid users = user3
read only = no
writable = yes
[share4]
path = /shared_folder4
valid users = user4,user5
read only = no
writable = yes

[share5]
path = /shared_folder5
valid users = user5
read only = no
writable = yes
Join Samba Server to Active Directory (Continued):
After installing the necessary packages and configuring the Samba server, you can join it to the
Active Directory domain using the realm command. Make sure to replace example.com with
your actual domain name and provide the appropriate administrative credentials:

sudo realm join [email protected] example.com


Restart Samba Service (Continued):
Finally, restart the Samba service to apply the changes made to the configuration file:

sudo systemctl restart smb


sudo systemctl restart nmb

You might also like