Monday, June 24, 2013

Session 2: IP Configuration

OVERVIEW
The discussion today is about the Internet Protocol (IP) Configuration. The discussion dwells on the understanding of IP addresses (composition of an IP address, configuration process, and its types).

About the IP Address
 A network is composed of different nodes. Every node of a network should have an IP address so that they can communicate with each other. IP address has different versions, but commonly used today is the IPv4. But due to the IP address exhaustion in February 03, 2011, IPv6 is now available to use.

IPv4 has a 32 bit address. It has 4 groups of 4-digit binary addresses. Every group consists of 8 bit binary address. 
                                      ________ . ________ . ________ . _________
                                        1st octet             2nd octet             3rd octet              4th octet
                                                                    8 bits                8 bits                   8 bits                    8 bits

On the other hand, IPv6 consists of 128 bit address. It has 8 groups of 4-digit hexadecimal addresses. IPv4 and IPv6 is not interoperable, meaning that two different computers with different IP version cannot communicate.

Network Address and Host Address
IP address can be divided into two address or ID: the Network Address/Network ID and the Host Address/Host ID. Basically, the network address occupies the first or higher octet, while the host address occupies the remaining octets.
                 N    .    H    .    H    .    H              (N = network address, H = host address)
And in order to delay the occurrence of IPv4 exhaustion, IP classes was introduced to allocate network addresses and host addresses accordingly.
          Class A       0 N . H . H . H            2^7 networks, 2^24 hosts (possible combinations)
          Class B     10 N . N . H . H           2^14 networks, 2^16 hosts (possible combinations)
          Class C    110 N . N . H . H           2^21 networks, 2^8 hosts (possible combinations)
          Class D   1110 N . N . N . H                
          Class E   11110 . H . H . H               

IP classes have ranges so that IP addresses can be easily identified, and to know what are the possible address can be. These ranges can be used publicly (networks).
          Class A         1    .    0    .    0    .    0       -       127    .    255    .    255    .    255
          Class B      128    .    0    .    0    .    0       -       191    .    255    .    255    .    255
          Class C      192    .    0    .    0    .    0       -       223    .    255    .    255    .    255
          Class D      224    .    0    .    0    .    0       -       234    .    255    .    255    .    255
          Class E      240    .    0    .    0    .    0       -       254    .    255    .    255    .    255
Also, there are available ranges for private networks that can be used by us :)
                            10    .    0    .    0    .    0       -         10    .    255    .    255    .    255
                         172    .    16    .    0    .    0       -       172    .      31    .    255    .    255
                       192    .    168    .    0    .    0       -       192    .    168    .    255    .    255

Types of IP
Static IPs are only used for private networks. The user of a computer can assign an IP address to a particular computer in a private network.
          How to change an IP address statically:
               ifconfig <interface> <IP address> netmask <netmask> broadcast <bcast>
          i.e.
               ifconfig eth0 172.16.9.6 netmask 255.255.255.0 broadcast 172.16.9.255
Dynamic IPs allows a router to assign an IP address to a computer.
         How to change an IP dynamically:
              dhclient <interface>
         i.e.
              dhclient eth0

Subnet Mask determines the network address from the host address.
                                                                                      Subnet Mask (Default)
          Class A     N    .    H    .    H    .    H                           255.0.0.0
          Class B     N    .    N    .    H    .    H                           255.255.0.0
          Class C     N    .    N    .    N    .    H                           255.255.255.0
          Class D     multicast
          Class E     experimental

i.e.
     172.16.9.0 - for network address
     172.16.9.X - for host address  
          => X should be between 1-254 for completing the IP address
          => if X is 255, then it is considered as broadcast address
          => if X is 0, then it is considered as a network address


PROBLEM STATEMENT
The students need to design a network to establish connection with at least two local hosts. The network can be implemented using the concept of IP configuration discussed above. The design should be done using the Network Simulator software.


GUIDES ON SOLVING THE PROBLEM
Designing a Network using Network Simulator (with 2 hosts)
The activity done today was to connect to two different networks together. The first network composed of a computer connected to a router, and same for the second network. To able to connect the two networks, there should be another network connecting the two routers. Thus, we assign a different network address for that network.

To be able to connect the two routers to the new network, let's say has an IP address of 192.168.0.X, Router1 should have an IP address with this format: 192.168.0.1, and Router2 with 192.168.0.2. Since, now they belong to the same network, they can now communicate to each other using ping command.

Here is the process on how to do these:
1. Open a terminal and type this command to be able to use the Network Simulator: java -jar netsim-3.0.jar. (If you don't have this package, download it from jachermocilla.org :D)

2. Start creating the network like this! :)
Connecting Two Different Networks
3. After creating the network, configure the computers with their respective IP addresses, Subnet Mask, and the Default Gateway. (Right-click the icon of the computer, then click 'Configure')

4. After configuring, the computers, do the following commands to connect the networks to each other.         (Right-click the icon for router, then click 'Console')
          Router1> enable
     Router1# configure terminal
     Router1(config)# interface fastethernet0/0
     Router1(config-if)# ip address <Router 1 IP address connected to Computer A> <subnet mask>
     Router1(config-if)# no shutdown
     Router1(config-if)# exit
     Router1(config)# interface fastethernet0/1
     Router1(config-if)# ip address <Router 1IP address connected to the Switch> <subnet mask>
     Router1(config-if)# no shutdown
     Router1(config-if)# exit
     Router1(config)# ip route <network address> <subnet mask> <gateway>
                    *Note: IP Route can have multiple entry
          Router1(config)# exit
     Router1# show ip route
     Router1# copy running-config startup-config
     Router1# disable
Configure the other router (Router 2).

5. After executing the commands, try to connect the two different networks using the ping command. (Right-click the icon for computer, the click 'Ping')
When Computer A (IP address: 192.168.1.1) pings Computer B (IP address: 192.168.2.1), this messages should be displayed:

When Computer B (IP address: 192.168.2.1) pings Computer A (IP address: 192.168.1.1), these messages should be displayed:



Designing a Network using Network Simulator (with 3 hosts)
The above example only uses two hosts (computers) in a network. How about if there are at least 3 hosts? Since a router only holds up to 2 hosts, we cannot it to connect 3 hosts. To achieve that set-up, we need to use a switch, which is connected to the 3 routers, each connected to a specific computer. In this set-up, we can now have a network with 3 hosts.

We just need to repeat all the steps specified in the example above.

The set-up of the network will be like this:
A Network with Three Hosts
The set-up contains the 3 hosts (computers), each connected to a router. And the 3 routers are connected to the switch. The switch will serve as a link to a router to another. To attain the correct connection, each computers and routers must have their correct IP addresses, and their configuration must also be correct.

Here are the configuration on each router:
Configuration for Router 1
Configuration for Router 2
Configuration for Router 3
It can be seen that IP routes in the terminal have two entries. It is possible to have multiple entries for IP routes when building a network with more than two hosts. The multiple entries will correspond to the other hosts connected to specific host, which will be configure.

To try if there is a successful connection between the three hosts, try to ping the other hosts connected to a specific host. Example, ping Computer B and C, which is connected to Computer A. Ping Computer A and C, which is connected to Computer B. And ping Computer A and B, which is connected to Computer C.
Computer A pings Computer B


Computer A pings Computer C
Computer B pings Computer A

Computer B pings Computer C
Computer C pings Computer A
Computer C pings Computer B
As seen at the screenshot, it can be said that the three hosts are connected to each other using a switch. Just ensure to configure the proper IP addresses of the computers and the routers, and have a correct connection to each other, so that the connection would be successful. :)))


LEARNING AND INSIGHTS
The discussion and activity elaborates the importance and use of IP addresses. Also, the establishment of connection between different computers using the IP configuration concepts is demonstrated by the Network Simulator software so well. I am fascinated with this activity because I am not that knowledgeable in these areas. And the fact that the series of numbers in every IP address symbolizes something, have helped me to understand it better. =)


CONCLUSION
The students learn how to configure local hosts using their respective IP addresses to establish connect with each other. The established connection can be via the router, a server or a switch. Also, the Network Simulator give a concrete example on how to do the configuration virtually. And lastly, it show how the IP addresses are important in every computer around the world.

C:Users/regina>Connection established! 
C:Users/regina>Bye! :D

Monday, June 17, 2013

Session 1: Secure Shell (ssh)

OVERVIEW
The activity today comprises of the introduction to data communications and networking using the Secure Shell (ssh) to connect to a remote server. SSH can be used to access a remote computer or a server by using a terminal. The Internet Protocol address or IP address of the said server should be known, so that a local computer can access it. 

PROBLEM STATEMENT
The students need to connect to a remote computer via a terminal using the ssh commands.

GUIDES ON SOLVING THE PROBLEM
The following are the steps needed to perform in order to connect to a server using ssh commands.

Adding a User to a Local Computer

Adding a user to a local computer
The screenshot shows that a user is successfully added to a local computer.
STEPS:
1. Create a username and password for the new user.
2. Type the command $sudo adduser <created username>.
3. Type the password of the local computer where the new user will be added.
4. The terminal will ask the user for its password.
5. The terminal will prompt the user that the user is added and ask for its personal information.
6. Confirm if the information is correct.
The steps specified and the screenshot allow the user to add a new user to a local computer.


Connect to a Remote Computer or Server via 'ssh' Commands

To connect to remote computer (server), you need to have a username and password created in adding a user to a local host. the username and password are needed to login in the remote computer using ssh commands. Also, the IP address of the remote computer is needed so that a user can access it since its IP address is different with the local computer you are using.
Connect to a remote computer using a ssh command
The screenshot above shows what the command on how to connect to a remote computer, and the output when a connection is established.
STEPS:
1. Login using your new account. Type the command $su <username>.        

2. The terminal will ask for your password. If the password is correct, the terminal will show the name  of the user and the directory in use. In the case of the screenshot, it displays "rmqarellano@ics-user:/home/ics-user$".
3. After logging-in, use the command $ssh 172.16.7.88 to connect to the remote computer. 172.16.7.88 is the IP address of a server in ITC.
4. The terminal will ask if you want to continue connecting to the server.
5. The terminal will ask for your password.
6. When the connection is established, the name in the terminal should change to "rmqarellano@paho:~$" as stated in the screenshot.



Configuring a Local Computer for a Passwordless Log-in
It is possible that when accessing the remote computer, a password is not needed to log-in, only the username is needed. The following steps and the screenshot will lead your way :).
Generating public/private key
STEPS:
1. Logout form the remote computer using the command $su <username>.
2. Go to the home directory of the local computer and search for the .ssh directory under your home folder. Go to that directory.
3. After changing to that directory, type the following commands:
                  $ssh-keygen -t rsa
                  $<enter>
                  $<enter>
                  $<enter>
             The terminal will show the key fingerprint.
Passwordless login
4. To use a secure copy (scp) to your home folder, use either of the following commands:
                  $ scp id_rsa.pub username@172.16.7.88:~/.ssh/authorized_keys
                  or
                  $ssh-copy-id username@172.16.7.88
5. Try to login again to the remote computer using your username. Notice that the terminal didn't ask for your password. :)


Broadcasting a Message using the 'wall' Command

Once the user is able to connect to a remote computer, he/she can send a message to the server where the other users can see. This can be done via the broadcast message using the wall command.
Broadcasting a message using the wall command
The screenshot shows how to broadcast a message when connected to a remote computer. The following steps will help the user to perform this task.
STEPS:
1. Type the command $mesg. make sure that it is set to yes (output is "y").
2. If mesg is set to yes, you can now use the wall command to broadcast a message. You can use the following commands fro broadcasting:
                       $wall <<< "<message>"
                       $echo "<message>" | wall
                       $wall [filename]
3. Use CTRL+D to terminate the wall.
         

Sending a Message to a Particular Local Host using 'write' Command

Aside from broadcasting a message where all users can see the message, you can also send a message to a particular user (much like a chat :D). This can be done using the write command.
Conversation with another user using the write command
This screenshot shows the how to communicate with a fellow user using the write command.
STEPS:
1. Get the username of the user you want to talk/chat with. Type the command $write <username of other user> [enter]. You should write your message after you click the ENTER key.
2. Use CRTL+D to terminate the conversation.


LEARNING AND INSIGHTS
The passwordless log-in is only possible to a particular local computer. In other words, if you use another local computer to access the remote server, it would not be passwordless because each local computer has its own IP address and public/private key. Using another local computer and use your login account from a different local computer is not possible.


CONCLUSION In this activity, the students learn how to connect to a remote computer (server), log-in without using a password, broadcast message, and send a message to a particular local host. The students perform the needed steps or guides necessary to solve the problem.


This should wrap-up the first session of our laboratory on data communications and networking :)