# Data Networking/Fall 2015/MeeraSudhakar
## Motivation

This project builds a deeper understanding of basic Networking fundamentals through practical implementation. The concepts that are part of the Data Networking class (TELE5330) became clearer through the implementation of this project.

## Understanding the Protocol

DHCP: This is a client/server protocol that automatically assigns IP-addresses to hosts in a network. It also provides related configuration information like the subnet mask and default gateway. DHCP supports static as well as dynamic IP addressing. This is a plug and play protocol. IP addresses are assigned automatically within the network, as opposed to being assigned manually by a network admin, which is cumbersome.
DNS: The Domain Name System runs transparently in the background. It converts human readable website names into computer-readable numerical IP-addresses. In this project, a master DNS server is being configured, and a slave DNS server is being configured as well to serve as a backup. These are authoritative DNS servers and provide high performance as they do not resolve recursive requests from clients.
Web Server: The Apache webserver is a popular way of serving web content on the Internet. More than one site can be hosted by a single Virtual Private Server (VPS). If multiple domains are configured on the same server, the visitor is directed to the specific directory for the domain he requested. There will be no indication at all that the server is responsible for other sites as well.
Firewall: A firewall is a network security system. It can be software-based or hardware based. It controls network traffic based on a set of rules. The Uncomplicated Firewall (ufw) is a part of the ubuntu package. It is an interface to the iptables. As part of this project, two clients have joined the network, and the web server has been configured to have a firewall against one of them.
Backup: System backup provides security to the network by retaining compressed versions of the filesystems of various nodes in the network. In the event of system crash, corruption or failure, the filesystem can be restored from the backup that was stored beforehand. Systems backups are taken as frequently as desired.

## The Requirements

* Implement a DHCP server that assigns IP addresses to the clients in the network
* Implement a web server that hosts one or more web page
* Implement a master DNS server and a slave DNS server
* Ensure that the clients in the network can access the web pages in the server by getting the name-to-IP address resolved by the DNS server
* Create backups of the client in the backup server and send them back to the client when required

## Steps to perform the setup / installation
### DHCP
#### Configuration

Assign a static IP to the etho interface of the DHCP server.
The IPv4 address 192.168.64.130 and the IPv6 address fe60::20c:29ff:fe5a:e3d0 have been assigned to the eth0 interface of the DHCP server. Reboot the DHCP server in order for these changes to take effect. Install the isc-DHCP-server on the VM by executing the command
Now, add the subnet, pools, fixed IP-addresses, lease time and excluded IP addresses to /etc/dhcp/dhcpd.conf for the IPv4 addresses:
Then add the same to /etc/dhcp/dhcpd6.conf for IPv6 addresses:
Restart the dhcp daemon:
Manually start the server for v6:
On the client, Client_1, edit the file /etc/network/interfaces so that the eth0 interface gets its IP address from the DHCP server.

#### Testing

Check if the client obtained its IP address from the DHCP by executing the following command:
Also, check the logs on the client for DHCP messages:

### DNS

Below is the configuration for IPv4. IPv6 is configured in the same way.

#### Configuration

Before the configuration, ensure that the hostname is configured properly on the master and slave servers: Master DNS Server:
Read the file to modify the system
Slave DNS Server:
Read the file to modify the system
Install BIND on both the master and slave DNS servers:
Master DNS Server Configuration:
Create the forward zone file:
We can use the pre-existing zone file as a template for this:
Edit the zone files:
Now, test the syntax of the modified files by executing the following command:
Check the individual zones files by executing the following commands:
If everything is fine, restart the BIND
Also, check the log file for messages:
Slave DNS Server Configuration:
Check the syntax of the modified files:
Restart the BIND service:
Check the log files for messages:

#### Testing

Execute the following commands on the client. "nslookup" is used to query the DNS to obtain name to IP address mapping or any specific DNS record. "dig" is a networking tool that can query DNS servers for information. It uses the operating system's local Domain Name System resolver library to perform its queries.

### Web Server
#### Configuration

Install Apache on the server:
Note that the two domains being created are examplemeera.com and testmeera.com. Create directories for these domains under /var/www/
These directories are owned by the root user. Grant permissions to the regular user to access these directories:
Modify permissions so that read access is permitted to the web directory.
These permissions are required because the server must be able to serve content and the user must be able to create content within the folders. Next, create pages for each of the virtual hosts:
Paste the following content in the file:
Similarly, create /var/www/testmeera.com/public_html/index.html Next, create virtual host files. These files specify the actual configuration of the virtual hosts and determines how the webserver will respond to various domain requests. The files for this project are being created by copying Apache's default file 000-default.conf.
The file content should be modified as shown below:
Repeat the same for the second domain:
The file content should be modified as shown below:
Enable the new virtual host files:
Finally, restart Apache to take the changes into effect:

#### Testing

This can be tested locally (if the DNS server has not yet been set up) by modifying the /etc/hosts file on the client
Now, open access these domains from a browser on the client. If everything is working fine, the browser should display the content of the created html file.

### Firewall
#### Configuration

Check the status of the firewall on the webserver
Add a firewall rule to block the IP of one of the clients in the network, and allow another one
Enable the firewall
Reload the firewall
Check the status of the firewall
Check if the iptables have been updated accordingly

#### Testing

Access the web server from the client that is not blocked (192.168.64.159). Notice that the web server can be accessed. Now, access the web server from the client that is blocked (192.168.64.129). Notice that the web server cannot be accessed. Also, check the file /var/log/apache2/access.log on the web server. Observe the status 404 for the blocked client, and the status 200 for the unblocked client.

### Backup
#### Configuration

Edit the file /etc/crontab on the client to schedule the backup of the filesystem:
The backups can sent back to the client via scp:

#### Testing

Check the backup server for filesystem backups taken at the time scheduled in the crontab.

## Integrated Testing

The procedure to test the entire system is below:
* Ensure that the DHCP server, Master DNS server, Slave DNS server are up and running.
* Check the IP address of the client using the command ipconfig. The IP address must be obtained from the range specified in the DHCP server
* Execute the command nslookup examplemeera.com on the client. Ensure that the DNS server is accessible by the client.
* Check the firewall on the webserver. Notice which client is blocked by the firewall
* Access the webserver from both the clients. One client displays the webpage, while it is blocked on the other client
* Check system time and modify the crontab accordingly on the client. Ensure that the filesystem is taken and copied to the backup server

## Future Prospects

Security and Robustness of the project can be improved by adding features like VPN, NIS, NFS, NTP etc.