# Data Networking/Fall 2014/DPDZ
## Group members

Darshan Patel Parismita Nath Jieling Ding Chengjie Zhu

## Behavior of the Protocol
### DHCP

Within a local network, DHCP assigns a local IP address to devices connected to the local network.The DHCP server manages a pool of IP addresses and information about client configuration parameters such as IP address, default gateway, domain name, the name servers, and timeservers.
* DHCP can simplify the job that assigns IPs to clients every time they enter. If same host returns to the network within the lease time it will be provided the same IP address.
* DHCP utilizes MAC address for assigning IPv4 addresses and can avoid conflicting in assigning IPs.

### DNS (Domain Name Server)

1. The main function of Domain name server is to translate domain name into IP addresses.
2. DNS is based on a hierarchical and logical tree structure called the domain name space. Different organization can create their own private IP address, using their own domain namespaces. The name space has a maximum depth of 127 levels.Domain names are limited to 255 characters in length
3. A zone is a portion of the DNS namespace generally stored in a file, and can contain multiple domains. Using the zone, the DNS server response to all the queries about hosts in its zone.
4.There are two types of servers, Authoritative – maintains the data Master- where the data is edited Slave – where data is replicated to Caching – stores data obtained from an authoritative server

### PXE boot

The PreReboot execution Environment (PXE) describes a standardized client-server environment that boots a software assembly, retrieved from a network, on PXE-enabled clients. After parsing a PXE enabled DHCP server DHCPOFFER, the client will be able to set its own network IP address, IP Mask, and to point to the network located booting resources, based on the received TFTP Server IP address and the name of the Network Bootstrap Program. The Client next transfers the NBP into its own random-access memory (RAM) using TFTP, possibly verifies it and finally boots from it. NBPs are just the first link in the boot chain process and they generally request via TFTP a small set of complementary files in order to get running a minimalistic OS executive (Linux kernel+initrd). When the small OS executive is alive it loads its own fully capable network drivers, a full TCP/IP stack, and the rest of transfers for booting or installing a full OS are performed not by TFTP but at this point using more robust transfer protocols like HTTP, CIFS, NFS, etc. Web server: Web Servers are used to serve Web Pages requested by client computers. Apache is the most commonly used Web Server on Linux systems.

## Command used
### DNS CONFIGURATION:

Step 1: Install Ubuntu package bind9 Sudo apt-get install bind9
Step 2: Configure the interfaces auto eth0
address 192.166.1.2 netmask 255.255.255.0 network 192.166.1.0 broadcast 192.166.1.255 gateway 192.166.1.1
Step 3: Restart networking daemons
Step 4: Create a Server name sudo nano /etc/hostname Ubuntu
Step 5: Once the bind9 is installed edit the following Named.conf.options sudo nano /etc/bind/named.conf.options forwarders
{192.166.1.1;
8.8.8.8; 8.8.4.4;};
Named.conf.local sudo nano /etc/bind/named.conf.local FORWARD ZONE zone "dpdz.com"
{type master;file "/etc/bind/zones/db.dpdz.com";}; REVERSE ZONE Server IP 192.166.1.5 zone "1.166.192.in-addr.arpa" {type master;file "/etc/bind/zones/db.192"; };
Step 6: Create the directory zones in /etc/bind/
Step 7: create two files in zone directory sudo cp /etc/bind/db.local /etc/bind/zones/db.autun.hom Edit the file sudo nano /etc/bind/zones/db.dpdz.com; BIND data file for local loopback interface;
Step 8: create reverse lookup zone file
sudo cp /etc/bind/db.127 /etc/bind/zones/db.192 Edit the file sudo nano /etc/bind/zones/db.192
TTL 604800
Step 9: check whether the zone files are working properly or not. Forward zone named-checkzone dpdz.com /etc/bind/zones/db.dpdz.com reverse zone named-checkzone dpdz.com /etc/bind/zones/db.192.
Step 10: Edit named.conf.resolv.conf sudo nano /etc/resolv.conf
Nameserver 192.166.1.5 domain dpdz.com search dpdz.com
Step 11: Restart the bind sudo /etc/init.d/bind9 restart
Step 12: check setting in log file tail -f /var/log/syslog there should not be any error. Step 13: Nslookup dpdz.com Nslookup 192.166.1.2

### Install and set up the DHCP server

Step 1. Making changes in the /etc/network/interfaces file sudo nano /etc/network/interfaces auto eth0 iface eth0 inet static address 192.166.1.5 netmask 255.255.255.0 gateway 192.166.1.1 Then restart it
sudo /etc/init.d/networking restart
Step 2. Set DNS sudo nano /etc/resolv.conf nameserver 192.166.1.1
Step 3. Install DHCP server on Ubuntu 14.04 LTS
sudo apt-get install isc-dhcp-server –y
Step 4. Edit file /etc/default/isc-dhcp-server to set the interface eth0
sudo nano /etc/default/isc-dhcp-server INTERFACES="eth0"
Step 5. Edit the file /etc/dhcp/dhcpd.conf
sudo nano /etc/dhcp/dhcpd.conf Set the domain name and domain-name servers: option domain-name "dpdz.com"; option domain-name-servers 192.166.1.2;
Step 6. Define the subnet, range of IP addresses
A slightly different configuration for an internal subnet.

### PXE boot CONFIGURATION

Step 1. Set up your Server sudo apt-get install dhcp3-server tftpd-hpa syslinux nfs-kernel-server initramfs-tools
Step 2. Configure DHCP server allow booting; allow bootp; filename "/pxelinux.0"; host pxe_client { hardware ethernet;fixed-address 192.168.1.5;}
Step 3. Restart DHCP sudo service isc-dhcp-server restart
Step 4. Configure the TFTP Server Configure tftp root directory sudo mkdir -p /tftpboot/pxelinux.cfg Copy across bootfile sudo cp /usr/lib/syslinux/pxelinux.0 /tftpboot Create default configuration file /tftpboot/pxelinux.cfg/default
Step 5. Set permissions sudo chmod -R 777 /tftpboot Start the tftp-hpa service: sudo /etc/init.d/tftpd-hpa start Configure OS root Create a directory to hold the OS files for the client sudo mkdir /nfsroot configure your /etc/exports to export your /nfsroot /nfsroot 192.168.1.2 (rw,no_root_squash,async,insecure)
Step 6. sync your exports sudo exportfs –rv

### Web Server CONFIGURATION

Step 1. config webserver： get installed apache2 sudo apt-get install apache2 sudo mkdir -p /var/www/dpdz.com/public_html sudo chown -R $USER:$USER /var/www/dpdz.com/public_html sudo chmod -R 755 /var/www sudo nano /var/www/dpdz.com/public_html/index.html
<html>
</html> sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/dpdz.com sudo nano /etc/apache2/sites-available/dpdz.com <VirtualHost *:80>
DocumentRoot /var/www/dpdz.com/public_html sudo a2dissite *default sudo a2ensite dpdz.com sudo service apache2 restart
Step 2. config firewall: only allow the our own network 192.166.1.0/24 to connect to webpage sudo nano /etc/iptables.firewall.rules File: /etc/iptables.firewall.rules
1 *filter 2 3 -I INPUT -p tcp --dport 80 -j DROP 4 -I INPUT -s 192.166.1.0/24 -p tcp --dport 80 -j ACCEPT 5 6 COMMIT sudo iptables-restore < /etc/iptables.firewall.rules sudo iptables –L Chain INPUT (policy ACCEPT) target prot opt source destination
ACCEPT tcp -- 192.166.1.0/24 anywhere tcp dpt:http DROP tcp -- anywhere anywhere tcp dpt:http
Chain FORWARD (policy ACCEPT) target prot opt source destination
Chain OUTPUT (policy ACCEPT) target prot opt source destination

## Testing
### DHCP

-sudo ifconfig

### DNS

sudo ifconfig
ifconfig

### WEB SERVER

ping DHCP server
Use IP address to surf the WEB
Use domain name to surf the Web

## Add-on items & Future improvements
### NFS

(Network File System) allows you to 'share' a directory located on one networked computer with other computers/devices on that network. The computer where directory located is called the server and computers or devices connecting to that server are called clients. Clients usually 'mount' the shared directory to make it a part of their own directory structure.

### VPN

Virtual Private Network lets you establish a secure connection over the non-secure Internet, e.g. from a notebook to an office server. Getting a VPN to work requires general knowledge on networks, and it may require some specific knowledge on routers, firewalls and VPN protocols.

### NIS

Network Information Service, or (originally called Yellow Pages or YP) is a client–server directory service protocol for distributing system configuration data such as user and host names between computers on a computer network.

### Backup

Backup refers to the copying and archiving of computer data so it may be used to restore the original after a data loss event. The primary purpose is to recover data after its loss, be it by data deletion or corruption.