# Data Networking/Fall 2016/Ad Hoc Network in Linux

LINUX PROJECT 1. Akshay Tandel 2. Vinay Nambiar 3. Kalpesh Shardul 4. Aditya Kadam

## Motivation

Most network operating systems are based on some variation of Linux. Linux influences every aspect of network administration, hence a network engineer should know Linux. The range and scope of networking technologies that use Linux is vast and growing. So for a successful career as a network engineer, knowing Linux is necessary. This project helped us to implement our networking concepts and skills and it gave us idea of Linux's flexibility and usefulness.

## Protocols and their behavior
### DNS

For humans, remembering websites by name is much easier than remembering their IP addresses. DNS is a service that allows us to do so. Domain Name Service (DNS) is an Internet service that maps IP addresses and fully qualified domain names (FQDN) to each other. In this way, DNS mitigates the need to remember IP addresses. It is even possible to associate multiple names to the same device to update the multiple available services. Computers that run DNS are called 'name servers'. The basic task of DNS server is to map the IP address of the query made by the user. It It also caches the query and its response for further use. This reduces time required to load the cached page.

### DHCP

DHCP stands for Dynamic Host Configuration Protocol. A DHCP server automatically assigns settings to hosts on network as opposed to manually configuring each network host. Computers configured to be DHCP clients have no control over the settings they receive from the DHCP server, and the configuration is transparent to the computer's user.
Important services provided by DHCP server to DHCP clients are: 1. IP address and netmask 2. IP address of the default-gateway to use 3. IP addresses of the DNS servers to use
The advantage of using DHCP is that changes common to the all hosts on the network, need to be configured only at the DHCP server, and all network hosts will be reconfigured. It is also easier to add new computers into the network, as there is no need to check for the availability of an IP address.
DHCP clients can get configured by DHCP server in following fashions: 1. Manual allocation (MAC address) 2. Dynamic allocation (address pool) 3. Automatic allocation

### Webserver

Web server is a computer system dedicated to accept HTTP requests from clients' Web browsers (Applications such as Firefox, chrome, Internet Explorer, Safari etc.), and serving them with HTTP responses along with web pages and objects. We have implemented Apache2. Apache is a popular Web server used on Linux systems.

### Firewall

A firewall is a security feature that filters the incoming and outgoing traffic in the network. IP tables is an extremely useful firewall utility built for Linux operating systems. We can manipulate the network traffic using IP tables by configuring chains and rules, connection specific responses.

### Backup

The protocols used for backup are rsync and ssh. Rsync is a protocol used to synchronize files in Ubuntu. It updates only that data that is not yet synchronized with the backup file. Ssh protocol provides a secure channel to send and receive files on Unix machines.It uses encryption and decryption at the end users. Crontab is used for scheduling backups.

## Requirements

Operating system: Ubuntu 14.04 DNS: BIND (Berkley Internet Naming Daemon DHCP: dhcpd (dynamic host configuration protocol daemon) Webserver: Apache2

## Steps and Commands used:
### DNS
##### DNS Master Server

Step 1: Install Bind9
Command:
Step 2: Restart the networking daemon
Command:
Step 3: Add a DNS zone to BIND9
Command:
allow-transfer { 192.168.1.90; };
zone "2.0.0.2.1.0.0.2.0.0.0.2.ip6.arpa" { type master; notify no;
Step 4: use an existing zone file as a template to create the /etc/bind/db.home.zzz file Command:
Edit db.linux.abc file as follows: $TTL 604800 home.zzz. IN SOA ns1.home.zzz. server.home.zzz. (
Now restart the BIND9:
Step 5: Setup reverse zone Command:
Now edit the rdb.home.zzz file as follows:
Now restart BIND9
Zone for ipv6

##### slave DNS Server

Edit the /etc/bind/named.conf.local:
Now restart BIND9

### DHCP

1. Install DHCP Server
2. Install radvd package
3. Set the static IP address of the DHCP server
4. Configure the IPv6 and IPv4 forwarding
5. Make eth0 as the default interface
6. Configure the DHCP server for ipv4
7. Edit the resolv.conf file
8. Configure the DHCP server for ipv6
9. Configuration of the radvd module
10. Reboot the System
11.
12. Restart the DHCP server

### Webserver

1. Install apache2
2. Make directories
3. Create Webpages for Each Host: open up an index.html
4. Create a HTML document that indicates the site it is connected to. Save and close the file when you are finished.
5. Do same procedure for test.home.zzz 6. Create New Virtual Host Files. Create the First Virtual Host File Start by copying the file for the first domain:
Open the new file in nano editor with root privileges:
Virtualhost file should look like this:
Save and close the file.
Copy First Virtual Host and Customize for Second Domain
Open the new file in nano editor with root privileges:
It should look like this:
Save and close the file when you are finished.
7. Enable the New Virtual Host Files
8. Restart Apache to make these changes take effect:
9. Set Up Local Hosts File (Optional)
It should look like this:
Save and close the file.
10. Test your Results In web-browser:

### Firewall

1. only 192.168.1.90 IP can telnet to webserver.
2. The below command will block all telnet access.
3. The below commands will block FTP.
4. To save IP tables use following commands:

### Backup

Step :
Command:
1. Install ssh server
2. Install ssh client on another VM
3. Generate public and private keys in the client
4. Copy the public key to ssh server
5. For creating tar file and securely sending to backup server.
6. For executing automatic backup

## Add-ons
### ARP cache poisoning

ARP is The Address Resolution Protocol a telecommunication protocol used for resolution of Internet layer addresses into link layer addresses, a critical function in computer networks. Scapy is a powerful interactive packet manipulation program. It is able to forge or decode packets of a wide number of protocols, send them on the wire, capture them, match requests and replies, and much more. It can easily handle most classical tasks like scanning, tracerouting, probing, unit tests, attacks or network discovery (it can replace hping, 85% of nmap, arpspoof, arp-sk, arping, tcpdump, tethereal, p0f, etc.). It also performs very well at a lot of other specific tasks that most other tools can't handle, like sending invalid frames, injecting your own 802.11 frames, combining technics (VLAN hopping+ARP cache poisoning, VOIP decoding on WEP encrypted channel, ...), etc. We have created a Python script using Scapy for poisoning the ARP Cache of a client system. Step : We have three different systems in our network. 1.Attacker 2.Victim 3.Web Server. Web server acts as a host for viewing the webpage. Victim can see the webpage hosted by the Webserver. Then we executed a Scapy script which floods the ARP Cache of the victim with its own MAC address. Thus, whenever the client send request at port 80 it will see the HACKED webpage hosted by the Attacker. Command: Python commands

### IPsec VPN tunnels

IPSec works at the network layer.We have implemented IPsec to protect data through internet. IPSec provides data security by encrypting and authenticating data, protection against masquerading and manipulation. When two machines want to make a VPN connection between them, they agree on certain settings and parameters. Eg. what type of authentication and encryption will be used within the VPN tunnel. This is generally called VPN negotiation. We have created transport IPsec VPN between two different systems. Step : Two different independent systems in the Virtual Machine can have encrypted communications. We have used Strongswan for having encrypted communications between them. Command: 1.apt-get install ipsec-tools strongswan-starter
2.nano /etc/ipsec.conf
3.conn red-to-blue
4.nano /etc/ipsec.secrets
5.<Left IP> <Right IP> : PSK "Your password here!"
6.ipsec restart
7.ipsec statusall
The same configuration needs to be done in the other system. Then, we can check the tunnel using ping command from the one side and then checking the ping through tcpdump esp

### NFS

Network File system allows a system to share directories and files with others over a network. By using NFS, users and programs can access files on remote systems almost as if they were local files. The commonly used data can be stored on a single machine and other machines over the network can access it. Home directories are configured on NFS server and are applied over machines on network. Storage devices can be used by other machines on the network. This may reduce the number of removable media drives throughout the network. Step 1:Configuring the NFS-Host
Command:
Create the Share Directory on the Host Server
Configure the NFS Exports on the Host Server
On the last line
create the NFS table that holds the exports of the shares
Start NFS service
Step 2:Configuring the NFS-client
Install a package called nfs-common on NFS client
Create the Mount Points on the Client Server
create each directory, and the necessary parent directories
Create the mount remote shares on NFS client