# Data Networking/Fall 2015/Dfjz
## Requirements
### DNS server

* Get a domain name for the start-up
* Assign a set of IPV4 and IPV6 that have to be used for this project
* Configure name servers to handle queries for the domain
* Document the details for the future users
* Assign one of the DNS server from BIND9, POSADIS or PowerDNS
* Create any 5 DNS records
* Create reverse domains in in-addr.arpa and ipv6.arpa
* Configure a Master DNS server and Slave server
* Test plan and implementation with example

### DHCP server

* Assign a set of IPV4 and IPV6 that have to be used for this project
* Dynamic allocation of network address
* The Client-Server protocol
* Test plan and implementation with example

### Web Server & Firewall

* Use only one command line tools and package
* Provide all the commands with a brief description
* Provide the changes you have made to the files/folders for configuring the webserver as well as the firewall. Create the basic page to be server by this webserver
* Make this page accessible to the clients in your network using the webserver
* Make your server the most secured one in all possible ways

### Back up

* Automate the process of backing up the data
* The backup file should be zipped and sent to a different server
* Describe briefly about how you backup automatically and how file transfer is made.
* Provide the command and configuration for sending the zipped file to a different location
* Mention which protocol you are using to complete this task

## Behavior of the protocol
### DNS
#### Functionality of DNS [1]:

The Domain Name System (DNS) is basically a large database which resides on various computers and it contains the names and IP addresses of various hosts on the internet and various domains. The Domain Name System is used to provide information to the Domain Name Service to use when queries are made. The service is the act of querying the database, and the system is the data structure and data itself.
The Domain Name System is an essential component of the functionality of most Internet services because it is the Internet's primary directory service. In an internet based system, the DNS sends a query to the internet which is further processed to extract the IP address using following processes:
* Recursive Process.
* Iterative Process.
Depending on the query forwarded by the client, the DNS can perform two functions:
* Forward DNS Query – Hostname to IP address.
* Reverse DNS Query – IP address to Hostname.
There are three classes of DN servers.
* Root DNS servers
* TLD- top level domain DNS servers
* Authoritative DNS servers

### BIND
#### Functionality of BIND [2]:

BIND is an acronym for Berkley Internet Name Domain. Version 9 was developed by Nominum, Inc.The BIND 9 software distribution contains both a name server and a resolver library.
The BIND software distribution has three parts:
* Domain Name Resolver A resolver is a program that resolves questions about names by sending those questions to appropriate servers and responding appropriately to the servers’ replies. In the most common application, a web browser uses a local stub resolver library on the same computer to look up names in the DNS. That stub resolver is part of the operating system. (Many operating system distributions use the BIND resolver library.) The stub resolver usually will forward queries to a caching resolver, a server or group of servers on the network dedicated to DNS services. Those resolvers will send queries to one or multiple authoritative servers in order to find the IP address for that DNS name.
* Domain Name Authority server An authoritative DNS server answers requests from resolvers, using information about the domain names it is authoritative for. You can provide DNS services on the Internet by installing this software on a server and giving it information about your domain names.
* Tools We include a number of diagnostic and operational tools. Some of them, such as the popular DIG tool, are not specific to BIND and can be used with any DNS server.

### Zones

A zone consists of some parts of the domain tree for which name server has complete information. It contains all domain names from a certain point downward in the domain tree except those which are delegated to other zones.

#### Authoritative Name Servers [3]:

There are two types of Authoritative Name Servers:
* Master server (primary name server) – A master server stores the original master copies of all zone records. A host master only makes changes to master server zone records. Each slave server gets updates via special automatic updating mechanism of the DNS protocol. All slave servers maintain an identical copy of the master records.
* Slave server (secondary name server) – A slave server is exact replica of master server. It is used to share DNS server load and to improve DNS zone availability in case master server fails. It is recommended that you should at least have 2 slave servers and one master server for each domain name.

### DHCP [4]:

The Dynamic Host Configuration Protocol (DHCP) is a network protocol used to assign IP addresses and provide configuration information to devices such as servers, desktops, or mobile devices, so they can communicate on a network using the Internet Protocol (IP). ISC DHCP is a collection of software that implements all aspects of the DHCP (Dynamic Host Configuration Protocol) suite. It includes:
* A DHCP server, which receives clients’ requests and replies to them.
* A DHCP client, which can be bundled with the operating system of a client computer or other IP capable device and which sends configuration requests to the server. Most devices and operating systems already have DHCP clients included.
* A DHCP relay agent, which passes DHCP requests from one LAN to another so that there need not be a DHCP server on every LAN.

### Apache [5]:

Apache is probably the most popular Linux-based Web server application in use. Apache2 supports a variety of features, many implemented as compiled modules which extend the core functionality. These can range from server-side programming language support to authentication schemes. Apache supports a variety of features, many implemented as compiled modules which extend the core functionality. These can range from server-side programming language support to authentication schemes. Some common language interfaces support Perl, Python, Tcl, and PHP. Popular authentication modules include mod_access, mod_auth, mod_digest, and mod_auth_digest, the successor to mod_digest. A sample of other features include Secure Sockets Layer and Transport Layer Security support (mod_ssl), a proxy module (mod_proxy), a URL rewriter (mod_rewrite), custom log files (mod_log_config), and filtering support (mod_include and mod_ext_filter).

### Firewall [6]:

Firewalls are computer security systems that protect your office/home PCs or your network from intruders, hackers & malicious code. Firewalls protect you from offensive software that may come to reside on your systems or from prying hackers. In a day and age when online security concerns are the top priority of the computer users, Firewalls provide you with the necessary safety and protection.

#### ufw - Uncomplicated Firewall [7]

The default firewall configuration tool for Ubuntu is ufw. Developed to ease iptables firewall configuration, ufw provides a user friendly way to create an IPv4 or IPv6 host-based firewall. ufw by default is initially disabled. From the ufw man page:

### Back up:

Backup refers to the copying and archiving of computer data so it may be used to restore the original after a data loss event.

### VPN:

VPN stands for Virtual Private Network. It is a network technology that creates a secure network connection over a public network such as the Internet or a private network owned by a service provider.

### NFS [8]:

Network file system (NFS) is based on the Remote procedure call which allows the client to automatically mount remote file systems and therefore transparently provide an access to it as if the file system is local. It is a client/server application that lets a computer user view and optionally store and update file on a remote computer as though they were on the user's own computer. The user's system needs to have an NFS client and the other computer needs the NFS server. Both of them require that you also have TCP/IP installed since the NFS server and client use TCP/IP as the program that sends the files and updates back and forth.

## Implementation
### DNS Server

Install DNS on local machine by using Ubuntu and Bind9 Step 1 : Change the interface accordingly (eth0 or wlan0) Command:
Step 2: Restart the network Command:
Step 3 : Install bind9 Command:
Step 4 : Remove the comments from the forwarders Command:
Step 5 : Define the entries for Forward and Reverse lookup zones

#### Master DNS

Forward zone:

#### Slave zone

Forward zone:
Reverse zone:
Step 6 : Create these files when bind9 starts Command: We need to copy these files to named.conf.local
Step 7 : Edit the forward lookup zone Command:

### DHCP Server

Install DHCP server in IPv4 on local machine Step 1 : Install dhcp server Command:
Step 2 : configure dhcp server Command:
Step 3 : assign fixed IP for webserver, master DNS and slave DNS, backup server, mail server Command: For webserver:
For master DNS and slave DNS:
for backup server:
for mail server:
Step 4 : start the dhcp service Command:
DHCP server in IPv6 on local machine Step 1 : Install radvd Command:
Step 2 : configure radvd.conf Command:
sudo nano /etc/radvd.conf
Step 3 : modify sysctl.conf Command:
Step 4 : start radvd service Command:

### Web Server

Install Web server on local machine by using Apache as the web server. Step 1: Install apache2 Command:
Step 2: To check whether the web server is listening on port 80 Command:
Step 3: Restart the web server Command:
Step 4: To edit the webpage for the server

### Firewall

Use ufw to set Firewall. It is built in along the Ubuntu system. Firewall is an application program which allows the system admin to configure the tables provided by the Linux kernel firewall.
Step 1: In order to block ICMP requests write the following command:
Step 2: In order to prevent SSH login, write the following command:
Step 3: In order to block FTP ports, write the following command:
Step 4: To block the port used by Telnet, write the following command:
Step 5: To block webpage write the following command:
Step 6: To start the firewall, write the following command:
Step 7: To shut dowm the firewall, write the following command:
Step 8: To block a certain ip access
Step 9: to unblock a certain ip access

### Back Up
#### Server side

Step 1: Install ssh Command:
Client side: Step 1: authorize client(web server) to backup server Command:
Step 2: use ssh-keygen to create an encryption key pair public and private key Command
Step 3: exit server
Step 4: copy id_rsa from server to client Command:
Step 6: automatic backup Command:

### Add-ons
#### VPN

Step 1: Install pptpd which is a package used to configure VPN Command:
Step 2: Edit the files in /etc/pptpd.conf and make the following changes
Step 3: Edit /etc/ppp/pptpd-options file:
Step 4: Restart the pptpd service Command
Step 5: Set user id and password Command:
Step 6:
Step 7: Firewall setting:

#### NIS

Step 1: Install nis portmap
Step 2: Edit the domain name NISServer when installed
Step 3: For NIS Client
Step 4: Edit the domain name NISServer
Step 5:

#### NFS

Commands to configure NFS:
For server follow these steps: Step 1:Install NFS Command:
Step 2:Edit the exports file Command:
Step 3:Make a directory called nfsroot:
Step 4: Restart the NFS server
Create a file under folder nsfroot
cd /home/project/nsfroot/
Step 5: For Client NFS install nfs-common Command:
Step 6: Create directory file named nfs
Mount file
Step 7: Link the 2 directories and the mount the file to the server Command:
Check the path of the shared folder Command:

#### NTP

Network Time Protocol is used for synchronization between computer systems.
Step 1: Installation
Step 2: configuration

#### Mail Server

Step1: Mail sever is configured using Postfix and dovecot Install postfix and dovecot using the following commands:
Step 2: assign hostname in /etc/hostname For our mail server, we have assigned mail.dfjz.com
Step 3: add a host in /etc/hosts The host with IP address is listed in this file
Step 4: configure postfix for SMTP-AUTH in /etc/postfix/main.cf
Step 5: Generate a digital certificate for tls:
Step 6: Configure certificate path
Step 7: uncomment smtps and submission lines from /etc/postfix/master.cf file
Step 8: add smtp auth for /etc/dovecot/conf.d/10-master.conf file
Step 9: In the /etc/dovecot/conf.d/10-auth.conf, add auth_mechanisms = plain login
Step 10:

## Step-by-step procedure to implement the project

* Implement DHCP server to distribute addresses dynamically to a client part of the network
* Assign network address and all its requirements
* Implement DNS server with at least five records using Bind9
* Implement Forward and reverse zones in the DNS
* Test Master and Slave DNS individually
* Test slave when master DNS is turned off
* Implement web Server using Apache
* Implement Firewall using above stated configuration
* Implement backup for the network
* In order to create a network, all the servers and clients must be connected to the same medium. This can be done using a switch or ad-hoc Network. For our project, we have chosen an ad-hoc network
* A hotspot is created to connect all the servers and clients
* Test the working of all the servers and the firewall and Backup

## Testing Plan

* Test the network
** Ping to every server successfully
* Test DNS Server
** use command ‘nslookup’
** Type in domain name to see the IP address is mapped
** Type in IPV4 address to see the domain name is mapped
** Type in IPV6 address to see the domain name is mapped
* Test DHCP Server
** Use ‘ifconfig’ to see the client or server can get the IP address (IPV4 and IPV6)
* Test Web Server
** Open the web browser, type localhost to see it can access the website
* Test MySQL
** Type the command MySQL –uroot –ppassword to login the MySQL Database
** Type the command show database to see it can get the table of database
* Test Backup
** Check the backup file in the backup server.
* Test VPN, NFS and etc.
** Connect to the VPN Server to see it can get successfully
** Type the command mount to get the NFS Server exported file, edit the file to see the server can get the latest edited file.
* Test Firewall
** Access the website after enable and shut down the firewall.

## Working with an example (Integration)
### DHCP Server

* Test of DHCP from VMware. The VMware host can get IP address and default router from the DHCP server.
* Test for DNS from Client2 IPv4, IPv6, Reverse DNS
* Test PXE from Client3

### DNS Server

* Firstly, the master DNS is set up and tested if the mapping is done accurately
* The slave DNS is then set up and the transfer of zones is verified
* Ping from either DNS is tested using two separate VM’s on VMware

## Future improvements

* More add-ons can be implemented such as VLAN, encryption, etc.
* Security can be configured by implementing alerts to the network admin, whenever a user attempts to perform an action as the root user
* Implementation of LDAP