Tuesday, July 13, 2010

Basics of IP Addresses

In IPv4 the address is 32 bit (4 bytes) long. We represent the address using dotted decimal notation. i.e. decimal numbers 0-255 (represent a byte), is called octet, and each of that octets separated by '.',

for e.g. 192.168.1.1 the hex equivalent (hexadecimal) of this address is C0.A8.1.1 and binary (1100 0000. 1010 1000. 0000 0001 . 0000 0001) i.e. the equivalent integer is 3232235777 in decimal and C0A80101 in hex.

IP Classification
  • IP addresses are classified into 5 categories
  • Helps in orderly arrangement and efficient application of addresses along different networks
  • classes can be A, B, C, D, E
Class NameStarting bits of of MSO (Most
significant bits of Most significant
Octet i.e.Left most octet)
Range of Left Most Octet
A00-127
B10128-191
C110192-223
D1110224-239
E1111240-255

Number of octets to represent net id and host id in different ip classes:- netid always start from left most octet. Based on the bits the default subnet mask can be determined so that to identify the netid and hostid.


IP Address divided into Net and Host Portions

Class A ip address (Address start with a number between 0 to 127 )

Class B IP Address (Address start with a number between 128 to 191 )

Class C IP Address ( Address start with a number between 192 to 223)

Class Name -(net id/host id )
A -(1/3)
B -(2/2)
C -(3/1)
thus the default subnet masks can be determined by checking the starting bits and the corresponding host and net id division above, thus the default subnet masks for each class is,
A - 255.0.0.0
B - 255.255.0.0
C - 255.255.255.0

This kind of addressing is classful addressing, but it result in wasting/insufficient number of ip addresses in different classes so there is another kind of routing that use classless routing and is known as CIDR (Classless Inter Domain Routing), it uses an ip with CIDR value denoted by preceding / (e.g. 192.168.1.1 /16) instead of the default subnet mask for classful address. Thus the classless addressing can use variable length blocks of ip addresses and thus solving the issue of address wasting or insufficient address in a particular class.

Reserved IP addresses
127.0.0.0 - Default Routing
255.255.255.255 - Global broadcast address

Private IP address ranges for different classes
class A - 10.0.0.0 to 10.255.255.255
class B - 172.16.0.0 to 172.31.255.255
class C - 192.168.0.0 to 192.168.255.255

Types of addresses
Unicast - one to one
Multicast - One to many
Broadcast - One to All
Not:e:-
IPv6 address is 128bit i.e. 16 byte long.

Monday, July 12, 2010

Why IP and MAC Addresses?

The MAC address is 48bit unique address assigned to any networking/inter networking device, which is embedded on the device and will not change anyway. But the IP may vary each time the device is plugged on to the network (if assigned a dynamic IP address), but there will be only that system on the network with the assigned IP (i.e. address is unique).

MAC address is used only in local communication, i.e. inside a local network only, if it goes out of a network it will use IP address to identify the device/machine.

MAC address is also called Physical address.

As we discussed, the IP address and MAC address are unique, i.e there will be no more than one system with same IP address or same MAC address. So there will be a confusion why to use both addresses?both are unique then why cant use IP or MAC itself?Why both are used in communication?Why the overhead/headache of confusing with both addresses?

Here the answer is,

The MAC address will vary each time the packet of data enters a new network, i.e. the source MAC address and Destination MAC address vary each time the packet reaches a new network, since the physical address is used to locate a system in a local network. The source and destination ip address will remain same always and is not altered with respect to the network changes, the ip should remain same to locate the destination, since the physical (MAC) address varies with network.

Sunday, July 11, 2010

Basics of computer Networking

There is no need to say what is computer networking, and what the use of it, all of you will be familiar with that all, so we are not discussing that topics, but just highlighting the basic terms related to computer networking,
  1. Different topologies :- Mesh, Ring, Star, Bus
  2. OSI Layers :- Physical, Data link, Network, Transport, Session, Presentation, Application
  3. Data link sub layers :- MAC (Media Access Control) and LLC (Logical Link Control)
  4. IP Address :- Unique 32bit (IPv4)/128bit (IPv6) number assigned to the devices in a network (Including Routers,Switches,Computers etc)
  5. Different networking and inter networking protocols :- TCP, UDP, ARP, RARP, ICMP, IGMP, DHCP etc
  6. Port numbers :- Port numbers like 80 for http, 21 -ftp, 22 -SSH, 23- Telnet etc
  7. MAC Address :- 48bit Physical Address (Unique)
  8. Networking and Inter networking devices :- Routers, Hub, Switches, Bridges etc
  9. Concept of Routing protocols, Gateways etc
  10. Concept of net id, host id, network address, sub netting, super netting, subnet Mask, simplex, half duplex and full duplex modes of communication
There are more terms related to networking, and we are not going through that all, and will discuss whenever necessary in future discussions.

The ip address is unique for the system in a network. An ip address has 2 parts, a network portion and a host portion. Network portion defines in which network that address belongs to; where as the host portion determine the position of that ip within that particular network.The subnet mask has the role of dividing the ip address in to network portion and host portion.

Cabling
the two ends of 8 color wires of Ethernet cable are connected in 3 different ways to for 3 types of cables as below,


Straight through

Orange white - Orange White
Orange - Orange
Green white - Green white
Blue - Blue
Blue white - Blue white
Green - Green
Brown white - Brown white
Brown - Brown

The straight through cables are used to connect dissimilar devices like PC and Hub, PC and Switch etc.
Cross over cable

Orange white - Green white
Orange - Green
Green white - Orange white
Blue - Blue
Blue white - Blue white
Green - Orange
Brown white - Brown white
Brown - Brown

Cross over cables are used to connect similar devices like hub to hub, PC to PC switch to switch etc.
Rolled or Roll over cable

Orange white - Brown
Orange - Brown white
Green white - Green
Blue - Blue white
Blue white - Blue
Green - Green white
Brown white - Orange
Brown - Orange white


Basic Digital Electronics

Before entering to the detailed networking topics, it is always better to start with basics of digital electronics and digital communication.

The digital electronics as the name implies is electronics of digits or digital data, whatever the data you have is not matter in this case, may be it is voice, video, image, text anything that is manipulated as digits. The digital communication thus should be the communication between digital equipments in digital form of data.

The basics of digital electronics is the binary arithmetic and logic, the binary is base 2 number system in which the possible two digits are 1 and 0, which in turn implies to the two states of electric/electronic component i.e. ON and OFF.

The usual arithmetic like +(addition) , -(subtraction), *(multiply), /(division) are also possible with binary numbers too, in addition to that in binary system we have some logical operations like AND, OR, NOT, XOR etc, for our topic, it is having much importance than other for later discussions.

And the basics of the digital circuits is based on this operations, in the form of simple electronic circuits called digital logic gates which will output the result of these logical operations. And here the output of such great operations,

The AND, OR and XOR gates have two inputs while for NOT only one input and all are having one output. Remember that in digital logic the output 1 is true and 0 is false

AND
its output is true(1) only if both of its inputs are true, all other cases it result false(0)
OR
Its output is true if any or both of the inputs is true, result is false only if both inputs are false
XOR
Its output is true if exactly one of the two inputs is true, i.e. odd number of true(1)s
NOT
It just negates or complements the input, if the input is true output will be false and if input is false output will be true

When the AND, OR, XOR combined with NOT, the output of the gates will be the opposite of the AND, OR, XOR operations and the resulting gates are NAND, NOR, XNOR respectively. Here the NAND and NOR are called universal gates and any other logic gate can be constructed using combination of any of these two gates.

So keep the operations in mind and remember these are the operation behind any digital device, whether it is computer, mobile, DVD player anything, and in the communication equipments like routers, switches, and your digital TV receiver.

Saturday, July 10, 2010

Dynamic DNS Servers

Sometimes you will get blocked when you try to access remote systems using the IP address itself. May be sometimes you are to check your local web server is running, that you setup in your home and having a dynamic IP address, when you asked your friend to check your server is running properly, and he/she types the url like http://117.193.123.113/mysite/index.php, sometimes he will get blocked from accessing your server, even if you enabled NAT and all done properly.

It is always easy to remember a site name than IP address and also the IP address, if you are having a dynamic IP will change each time (not always) when you reset the modem based on availability of IP addresses. In such cases there are services that provide you the facility of dynamic DNS servers, where you can create your domain, i.e. a sub domain of the service provider's top level domain. You can set the sub domain to point to the IP address you have. You need to update the ip corresponding to the domain each time if it changed (usually if the modem resets).

Suppose the above case, you are having the ip 117.193.123.113 and you want to test your home ftp server then you can create a domain like myhomeftp.dyndns.com and you can set that point to your home PC that is assigned an ip 117.193.123.113 (set up NAT to share the same public ip between modem and PC, so that the service running on your PC will be available to the public).

There are many such providers offering you the dynamic DNS, and i used the same service from dyndns.com for test purpose and also for the company i worked for, to use the ftp server i setup for the company, that I explained in previous article, as it is a static ip no need to update the dns server frequently.

They provides a number of choices for you to select the top level domain, like dyndns.com or homeftp.net etc.

Friday, July 9, 2010

Remote Connect via SSH or Telnet

We can connect to a remote computer using telnet (port 23) or SSH (port 22) protocols based applications. Suppose the server running an ftp service, and the server is based on operating system ubuntu. When you install ubuntu server with default options, it will install the SSH service too, also if you want setup telnet server on ubuntu(if it is not already installed). Check it using the command telnet IP-Address/Name of the system, or if you are already on the terminal of the system running the service use the command telnet 127.0.0.1 (address for the local host). If it asks for the user id and password then is is working fine, else require new installation.

To install telnet follow the steps
  1. Install inetd super server using command sudo apt-get install netkit-inetd
  2. Install telnet using the command sudo apt-get install telnetd
  3. Restart the inetd service using command sudo /etc/init.d/inetd restart
  4. Now the server is ready and can access using the command telnet ip-address/computer-name, can test it from terminal using command telnet 127.0.0.1
  5. Now can use the terminal/command prompt as you work on your terminal itself
  6. Sometimes the telnet server will show you the available menu items that you can select to perform the tasks available(you have permission) to do, for e.g. if you telnet your modem from command prompt (for e.g. telnet 192.168.1.1), you can find a set of menu items you can select it to configure the modem
Telnet and SSH provide almost the same functionality but SSH is secure than telnet.

SSH
In most cases the ubuntu server will install the ssh server when you install ubuntu. If you want access the ssh since telnet is not secure, to access the system using ssh, you can use any ssh client programs like putty. Here is how can use putty to access the system via ssh
  1. Download putty and run it
  2. Enter the host name/computer name/ip address of the system you want connect to
  3. By default, the port address will be 22 and if you are not altered the default setting for ssh on your server leave as it is, otherwise change the port address as you set for the ssh server
  4. Then click open, if it is able to connect to the server via ssh will open the terminal and you can do anything with that server that you have permission to (or can access the programs that you have access to)

Thursday, July 8, 2010

Basic Networking Commands

Here is some basic commands used in networking world
  1. ping :- ping command is used to check the computer is active in the network(ping IP-address/Computer Name, eg:-ping 192.168.1.1 or ping mydesktop or ping google.com)
  2. ipconfig :- to find out the details regarding the active network connection i.e.associated ip address, physical address, subnet mask, default gateway etc (ipconfig/all)
  3. netstat :- to find out the different ports active on the system. It displays the port number and protocol(TCP/UDP), local address with port number (local address : port), foreign address(foreign address : port), state (Active or not i.e. connection established or wait), use the command like (netstat)
  4. tracert :- it trace the route to a particular computer, for e.g:- if you want find the route to google.com so that you can find whatever IP addresses are involved in accessing google website, or which routers are involved in routing your request to google.com at that particular time(tracert google.com), remember that the table may vary in different intervals of time, the table you got at the moment may/may not be same as the table you will get after few seconds

Remote Connect

Sometimes we will be required to configure a remote system, for e.g:- a technical support officer in India will be informed to configure the web server running in US data center, in such cases we will be required to use programs that help in remote connectivity.

For windows (Windows XP/ 2003 server) we have remote desktop connection, that help to connect to a remote windows desktop and we can configure it the same way as we configure our desktop machine.

For that follow the steps
  1. Remote desktop connection from Start->All programs->Accessories->Communications->Remote Desktop Connection.
  2. You will be prompted for the computer you want connect to, enter the IP address or the domain name of the computer you want connect to (eg:- 59.129.180.121 or myserver.com), if you are trying to connect to a system in the same local area network as yours then enter the system name
  3. Click Options and enter the user name and Password
  4. Click Connect
  5. Then if the details provided are all correct then you will be connected to the remote dektop and you can work on it as the same way as you work with yours
  6. Also verify that you have checked the Allow remote assistance invitations to be sent from this computer (Select Start-> Control Panel -> System -> Remote)
At the server side you must setup the system so that it is ready to accept remote desktop connectivity, for that you want do is that
  1. Select System from Start->Control Panel
  2. Select the Remote tab
  3. Check Allow users to connect remotely to this computer
  4. Click Apply
  5. Also you can select the users who can be permitted to access the computer remotely by selecting the Select remote users
  6. Select Windows Firewall from Control panel
  7. Select the exceptions tab
  8. Check the Remote desktop and click OK
Also check at the server side that you have enabled NAT (is explained in the previous article)

Wednesday, July 7, 2010

Setup NAT for Public Access

Whatever service installed on a server will be available to the local network inside the organization only if the NAT(Network Address Translation) on modem is not properly set. This is how I Setup NAT on my UTI StarCom Modem provided by BSNL with their broadband (netone) connection.

  1. From terminal/command prompt typed the command ipconfig/all and pressed enter key
  2. Found the Default Gateway address from the list(e.g:- Default Gateway : 192.168.1.1)
  3. Opened the web browser Mozilla Firefox/Internet explorer/Google Chrome/Any other
  4. Typed the URL http://192.168.1.1 in the address bar and pressed enter (replace the default gateway address if required)
  5. It prompted for the user id and password, entered it and pressed enter again
  6. Selected Advanced setup->NAT from the left navigation menu
  7. There are two options DMZ host and virtual servers, selected DMZ host and and typed the IP address of the system running the ftp/web/other service(e.g:-192.168.1.100)
  8. Clicked Save/Apply button and then restarted my modem (not always required)
  9. I checked my PC running the service for its IP address, for that I used the command ipconfig/all again from command propmt, it displayed my IP address as 192.168.1.4
  10. Then I changed my IP to 192.168.1.100 by selecting My Network Places->View Network Connections->Local area connection->Properties->Internet Protocol(TCP/IP)->Properties->Use the following IP Address
  11. Entered the IP 192.168.1.100 and subnet mask 255.255.255.0 and default gateway to 192.168.1.1, the same gateway address i got in step 2, clicked OK/Apply
  12. The same gateway address is entered as Preferred DNS server
  13. Now the service is available to the public

Friday, July 2, 2010

FTP Server on Windows XP

Today want a talk about how did I setup an FTP server on my windows XP. For this I used Filezilla server. First I donwloaded the Filezilla server and installed on my Windows XP based desktop PC. Then I edited the settings for the Filezilla server, for that I opened the server interface and changed the welcome message and added a group and few users to it. The steps are noted as below,

  1. Downloaded and installed filezilla on my desktop PC named desktop
  2. Opened the admin interface clicked OK after entering the server address (127.0.0.1 by default) , port and admin password
  3. Selected the menu Edit->Settings
  4. From the left tree view selected General settings->Welcome message
  5. Changed the custom welcome message and clicked OK
  6. Then selected menu Edit->Groups
  7. On the right of the window clicked Add, then Entered the group Name "ftp users" and clicked OK
  8. Created a folder named ftp on the D- drive
  9. Clicked shared folders on left and clicked the add button on left side
  10. Selected the folder d:\ftp, set the permissions (read/write/execute etc) and clicked OK
  11. Selected menu Edit->Users
  12. Clicked Add on right side and added user "ftp user" and selected the group he belongs to, i.e "ftp users"
  13. Set the password for the user
  14. Selected shared folders on left side and added the folder d:\ftp and set the permissions for the folder
  15. Clicked Ok
  16. Finally on Start->Control panel select windows firewall and select Advanced tab and select the Connection you are using (eg:- Local area connection-LAN), and click settings and then check the FTP server in the list showing the services running on your computer the click OK twice
  17. Test the ftp server from other computer on the network using the url ftp://desktop, if you are using filezilla client enter the desktop as host and enter userid and password click quick connect
Download filezilla server and client programs from http://filezilla-project.org/

Thursday, June 24, 2010

FTP Server on Ubuntu Server

Today to talk about how I setup an ftp server for my company. As my company works on product and need to send the new releases to clients(this was done through adrive.com), my boss told me to setup an ftp server for the company so that the release can be easily copied to the server on LAN and then the clients can download it from the FTP server, so that the adrive upload could be eliminated. There is already an SVN based code server with ubuntu server operating system active in the company, so the remaining to do was not a tough job. here is how I did it with proftpd,

the following few commands made the ftp server running/active,

  • sudo apt-get install proftpd
  • sudo vi /etc/shells (appended the following line to the opened file)
/bin/false
  • sudo mkdir /home/release (this created a folder/directory named release inside /home directory)
  • sudo useradd client -p client -d /home/release -s /bin/false
  • sudo chmod 775 /home/release
  • sudo vi /etc/proftpd/proftpd.conf (edited the file as below)
Changed/added/Uncommented(i.e. removed #) the four lines in the file as
DefaultRoot /home/release
DefaultRoot ~
DenyFilter \*.*/
DisplayLogin /usr/msgs/welcome.msg (Setting up This will display/send a welcome message when user is authenticated)
  • sudo vi /usr/msgs/welcome.msg
Added the following line to the welcome.msg file
Welcome %U to My Company's FTP Server
Login Time is : %T
  • sudo /etc/init.d/proftpd restart
Now the ftp server got ready. I was able to access the ftp server using the URL
ftp://client:client@myftpservername
Also I accessed the same using filezilla where the host was "myftpservername" and user "client" and password "client".

Later I compelled to change the client password so i did it using
  • sudo passwd client
Then it asked for the new password and I updated the client password with the "new password"

For further clarifications or making server more secure go through this link http://ubuntuforums.org/showthread.php?t=79588