Martes, Hulyo 23, 2013

In today's exercise, we learned and reviewed about router configuration and DHCP. The main goal of the exercise is to share the internet connection from a PC that has established connection to the internet, (making it a router for another PC with no internet connection) with another PC that doesn't have an established connection to the internet.

In order to do this, we first prepared and configured Computer B (the computer connected to a wired connection) We first check the ifconfig settings, and assigned a static IP address to the interface connected to Computer A, which is wlan0. (Since, the connection of Computer A to Computer B is wireless) as you can see in this image below: 
We also checked if IP Forwarding is enabled by the use of the command: 

#cat /proc/sys/net/ipv4/ip_forward

and as you can see in the image, it returned "1" meaning, IP Forwarding is enabled. We then set the appropriate firewalls settings for computer B, as shown in this image: 

We then check if Computer B is still connected to the internet by doing a ping to www.google.com and then we checked the contents of the file /etc/resolv.conf and copied it to computer A's /etc/resolv.conf. 




 We then proceed with configuring Computer A 
We assigned a static IP address to the interface connected to Computer B and then we set the IP address of computer B as a default gateway by typing the commands: 

#route add default gw 192.168.18.254
#route -n

We then tried to ping computer B using computer A: 
 and also tried to ping a website, www.google.com to check if Computer A has an internet connection already and successfully this is the result: 
This is somewhat a confirmation that Computer A has accessed to the internet through Computer B. 

B. Using DHCP Servers: (Another way of doing the process of letting another computer connect to the internet by the means of wireless connection with another computer that has wired connection to the internet)

1. We first installed  the DHCP server and did the following steps: 
We then created the configuration file /etc/dhcp3/dhcpd.conf  
to automate  the configuration for Computer A.

The file looks like this.
we set the range to 192.168.18.166 until 192.168.18.170, these are the set of IP addresses that the DHCP server will lease to computers wanting to connect to it. We then set the option router by the IP address of 192.168.18.1. Specifically, we just configured the lines 38 -40. Then after that we run the server by typing in the command: 

#/etc/init.d/dhcp3-server/ restart

As shown in the image below:  

Then in Computer A, we run the dhclient command to request for a host configuration information on to the server.

#dhclient wlan0

wlan0 is the interface connected to computer b. 
In order for us to see if Computer A had a hold of the IP address from the DHCP server, we viewed the leases file in Computer B to see what IP address was lease upon to Computer A and it showed us this results:
As shown here, Computer A successfully grab a hold of an IP Address made to be lease from the DHCP server. 

After confirming that Computer A is connected to Computer B by the use of DHCP server we proceeded with the cleanup.


We stopped the DHCP server and remove the configuration file: /etc/dhcpd.conf
as shown in the image above


As a whole, the process was tedious and required a lot of amount of time, effort and patience. Some of the aspects of the exercise was also quite confusing but it gave us a learning towards making a certain computer to be a router to another computer. 

Questions: 
1. Using the man pages for iptables, briefly explain what was done in step 5 in configuring
Computer B. Describe the parameters used in the iptables command.
Answer: 
- iptables -F -- flushes the selected chain, (or all the tables in the chain if there is nothing selected). similarly, it also deletes the rule one by one. 
- iptables -P INPUT ACCEPT -- sets policy for the chain to the given target. 
- iptables -P OUTPUT ACCEPT -- sets policy for the chain to the given target. 
- iptables -P FORWARD ACCEPT --  sets policy for the chain to the given target.  
- iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE --  specifies the packet matching table in which the following commands should operate on, in this case it's nat. -A then appends a rule to the selected chain. In this case, the rule is POSTROUTING. -o followed by ethY (name of the interface) this part of the command sets the name of the interface (eth0) via which a packet is going to be sent. -j MASQUERADE specifies the target of the rule or what it does if the packet matches it. In this case, MASQUERADE is the target of the rule.
2. What are the options you used in /etc/dhcpd.conf?
Answer: the options that we used are the IP addresses of computer A and computer B.
3. How do you assign a fixed IP address to a computer?What information do you need?

Answer: We just need the subnet, gateway and subnet mask.





Walang komento:

Mag-post ng isang Komento