# Data Networking/Fall 2016/WTJ

WTJ for (Pan Wu, Jiayi Tong and Shi Ji)

## Introduction

This page is about our Linux project which creates a small networking environment including DNS server, DHCP server, Web server&Firewall and backup. Futhermore, the add-on parts are also be finished successfully. The process will be explained in details as following sections.

## Behaviour of Protocols
### Domain Name System

i. Assigned the static IP address for the server. 
ii. Assigned bind9 DNS server.   iii. Created 5 type A records.   iv. Used both ipv4 and ipv6 address in my implementation of records.
v. Created reverse domains in in-addr.arpa and ipv6.arpa.
vi. Configured the slave DNS server that can automatically update with  master DNS server.

### Dynamic Host Configuration Protocol

i. Assigned the static IP address for several important servers like web server and DNS server.
ii. Used ipv4 and ipv6 address pool.
iii. Allocated dynamic network address to the clients  .
iv. The client-server protocol .
v. Set the IP address leasing time for clients.

### Webserver & Firewall

i. Assigned the static Ip address for the web server.
ii. Created a basic page to the server, and used phpmyadmin to manage web server database.   iii. The page is accessible for all other hosts .
iv. Set the firewall for webserver by using iptables.

### Back up

i. Automated the process of backing up the data.
ii. Backup file has been zipped and sent to the different server.
iii. Backup file has transferred automatically.

### Add-on

i. Used scapy to complete arpspoof and let client have a wrong arp cache for webserver, so the client will wee a Hacked Web-Page when it request to the original webserver.
ii. Used openswan to set up a IPSec VPN tunnel that one host can connect to the other host which in the different subnet.
iii. Used the NFS to make two clients share file.

## Commands used
### DHCP

Step1: Install DHCP server package Command:
Step2: configure DHCP server Step2.1:configure file: /etc/default/isc-dhcp-server to change the default interface to our machines interface. Command:
Step2.2:configure file: /etc/dhcp/dhcpd.conf, there are several places we need to change. 1.Set up lease time for clients and set up domain name Command:
2. Set up the network with mask and assign the range of IP, along with the IP addresses of the router and dns server in the network:
Command:
3. Then we set the several reserving IP address for particular clients and servers.
Command:
4. We set a static IPv4 and IPv6 address for interface ens33 of the DHCP server
5. Then set IPv6 DHCP server
5.1
Command:
5.2 configure interface ens33 with ipv6
Command:
6. Finally, restart DHCP service
Command:

### DNS

1. Master DNS server
1) Firstly, We need to install the DNS server by type
Command:
2) Secondly, we can define some zones that provide the domain name and the type of the dns server.Then, a domain name “wupapa.com” is defined as shown as the following figure. The IPv6 zone and the reverse zone are also defined.
Command:
3)Thirdly, changing the data files in the created zone file. The local file which contains the initial data would be copied to the created file. For example, the zone file our group created is “db.wupapa.com". Then, the initial data could be changed by using vi editor. The following figure shows the designed data file.
Command:
4)Then, the reverse zone file also could be modified. Copy the file to the created reverser zone file.
Command:
5)Fourthly, we need to define the default “resolv” file.
Command:
6) The last move for the master DNS server is restart this server.
Command:
2. Slave DNS server
The setting of slave DNS is shown below. There is no need to define the data file in the defined zones. It will be updated by the master DNS server. The only thing we need to do is create the slave zone for the DNS server.

### Web server & Firewall

1. Set up LAMP environment for web server
In this section, i used LAMP to configure the web server. LAMP stack is a group of open source software that are used to get web servers running. The acronym stands for Linux, Apache, MySQL, and PHP.
1.1 Install apache2 Command:
1.2 Install mysql and active it
Command:
1.3 Install PHP
Command:
1.4 Start web server
Command:
2. Set up our own home page for web server
Command:
3. Test web server using other clients
After typing in the IP address of web server, the home page was shown. It means the web server works.
4. Firewall
1) install the "ufw" program
Command:
2) Changing the setting of "ufw"
Command:
3) For example, deny a IP address

### Back up

1. With the use of python, it backs up web data and database.
Command:
Then edit the mysql_databak.sh
Command:
2. Set up a process that data backs up automatically
Command:
Achieved timing mission by using crontab.
The screen shows 47 * * * * ./mysql_data/mysql_databak.sh. It indicates the server will automatically run the script file mysql_data.sh each hour. It means web configuration file and database of web server will be backup hourly.
3. Automatically send backup file to other servers
1) In this part, We used scp command to transmit a file to other hosts.
Command:
2) Not only we need to fulfill the function that file will send to other hosts manually, we should also set up the process that can run automatically.
First, we set these two transmitting files hosts without password.
Command:
By using these two command lines above, we transfer our file between two hosts without passwords.
Finally, the "scp" command is used into crontab.

## Testing
### DHCP Test

Check the DHCP server is running or not
Command:
This command is looking at the DHCP is active or not

### DNS Test

1. nslooup
We can use nslookup to find the ip address of a hostname
Command:
2. host
We also can use "host" to find both ipv4 address and ipv6 address of a hostname
Command:
3. dig

### Web server Test

Check the web server's status
Command:

### Firewall Test

Command:

### scapyTest

Look at the arp of the computer
Command:

### VPN tunnel Test

Check the status of the VPN tunnel
Command:

### nfs Test

Command:

## Future improvements

1) Improve the security, make it more robust.
2) Improve the interface of the Web server, and add some other functions.
3) Add Mail Server to improve the whole system.