In this part, I would like to give explanation to some terms which are useful in setting an interface up.
IP address: It is an identifying number and every computer connected to the Internet has it. They are expressed in decimal form. A typical IP would look like: 216.27.61.137. But computers communicate in binary form , so it would look like: 11011000.00011011.00111101.10001001. Every part of the IP is called an octet, because the binary form of every number takes 8 places.Each octet can have the value from 0 to 255. There are 4.3 million possible IP numbers, although not all are in regular use.
Class A: A class of IP numbers. This class is designed for large networks, such as governments or major international companies. The first octet in class A IP numbers is identifying the class (it can have value from 0 to 126) , and the other three octets are identifying the host:
Class(from 0 to 126) Host(node)
123. 12.32.231
Class B: This class is used for smaller networks. The first octet has value from 126 to 191. In class B IPs, the first two octets are used to identify the network. The other two are to identify the host:
Class (the first from 126 to 191) Host(node)
129.34. 43.53.
Class C: Used for small networks. The first octet has have value from 192 to 223.Here, the first three octets are used to identify the network. The last octet is the Host octet.
Class Host(node) 195.26.134 56
Broadcast: IP used to send messages to all computers on the Internet. It always has value of 255.255.255.255.
Netmask: A set of four number blocks. Used to determine the size of the net, class part of the IP and the host(node) part. The positions that has value in the netmask are reserved for the net part of the IP, while the positions which are filled with zeroes are dedicated to the host part of the IP. Class A netmask: 255.0.0.0
After installing the networking devices you need, such as modems, Ethernet cards and so on, you need to make them known to the kernel networking layer. On start up, Linux systems try to recognize the devices and to create automatically the interfaces for them. That is done by the initialization scripts, each time you boot the system. But, however, you can set up an interface manually by using the ifconfig command. Ifconfig is used to make an interface accessible to the kernel. It also activates a specific interface, also known as “bringing up” the interface. The usage can be pretty simple (general form):
$ifconfig interface_name ip-address
This creates an interface named by the value of interface_name, and has ip defined in ip-address parameter.
The first interface which is defined is the local loopback interface (lo). It can be easily activated:
$ifconfig lo 127.0.0.1
Ifconfig also looks up into the /etc/hosts file, and can associate the hostname localhost to the IP 127.0.0.1. The first entry in the /etc/hosts file is dedicated to localhost.
$cat /etc/hostname | grep localhost localhost 127.0.0.1
You can check the configuration of every interface, by giving the interface name as parameter to the ifconfig binary:
$ifconfig lo lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:3924 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 Collisions:0
Creating Ethernet interfaces is simple as creating local interface. But, if you use subnetting, it would be wise to specify the netmask also, because ifconfig can give wrong netmask value. For example, we have subnetted a class B network into several class C network. So, for the IP 171.15.3.5., the ifconfig would give the value of class B netmask: 255.255.0.0. But, that is incorrect, so we specify the netmask:
$ifconfig eth0 171.15.3.5 netmask 255.255.255.0
So, we check:
$ifconfig eth0 eth0 Link encap 10Mps Ethernet HWaddr 00:00:C0:90:B3:42 inet addr 171.15.3.5 Bcast 175.15.3.255 Mask 255.255.255.0 UP BROADCAST RUNNING MTU 1500 Metric 1 RX packets 0 errors 0 dropped 0 overrun 0 TX packets 0 errors 0 dropped 0 overrun 0