Setting Up a Network Interface Card
Loopback Interface
1.
Even if the computer is not connected
to outside networks, an internal network functionality is required for some
applications.
2.
This address is known as the loopback
and its IP address is 127.0.0.1.
3.
You should check that this network
interface is working before configuring your network cards.
4.
To do this, you can use the ifconfig
utility to get some information. If you type ifconfig at a console
prompt, you will be shown your current network interface configuration.
5. If
your loopback is configured, the ifconfig shows a device called lo with the
address 127.0.0.1. If this device and address are not shown, you can add the
device by using the ifconfig command as follows: ifconfig lo 127.0.0.1
6. You
then need to use the route command to give the system a little more information
about this interface. For this you type: route
add -net 127.0.0.0
7.
You now have your loopback set up and
the ifconfig command shows the device lo in its listing.
Configuring
the network card
1.
Configuring a network card follows the
same procedure as configuring the loopback interface.
2.
You use the same command, ifconfig,
but this time use the name ‘eth0’ for an Ethernet device.
3.
You also need to know the IP address,
the netmask, and the broadcast addresses.
4.
These numbers vary depending on the
type of network being built.
5.
For an internal network that never
connects to the outside world, any IP numbers can be used, however there are IP
numbers typically used with these networks.
RESERVED NETWORK NUMBERS
Network Class
|
Netmask
|
Network Addresses
|
A
|
255.0.0.0
|
10.0.0.0–10.255.255.255
|
B
|
255.255.0.0
|
172.16.0.0–17.31.255.255
|
C
|
255.255.255.0
|
192.168.0.0–192.168.255.255
|
6.
If you are connecting to an existing
network, you must have its IP address, netmask, and broadcast address. You also
need to have the router and domain name server addresses.
7.
In this example, you configure an
Ethernet interface for an internal network. You need to issue the command:
ifconfig eth0 192.168.1.1 netmask 255.255.255.0
broadcast 192.168.1.255
8.
The result of above is file get
created in /etc/sysconfig/network-scripts called ifcfg-etho
9.
We can check this file by issuing
following command :
[root@main~]# cat /etc/sysconfig/network-scripts/ifcfg-etho
Note : A broadcast address is
a logical address at which all devices connected to a
multiple-access communications
network are
enabled to receive datagrams. A message sent to a broadcast address is typically received
by all network-attached hosts, rather than by a specific host.
Configuring
an internal network
1.
Now you have a network device
configured for one computer, to add additional computers to your network you
need to repeat this process on the other computers you want to add.
2.
The only change is that you need to
assign a different IP address. For example, the second computer on your network
could have the address 192.168.1.2, the third could have 192.168.1.3, and so
on.
3.
In addition to configuring the network
cards on each of the computers in the network, three files on each computer
need to be modified. These files are all located in the /etc directory and they
are:
i.
/etc/hosts
ii.
/etc/hosts.conf
iii.
/etc/resolv.conf
4.
The /etc/hosts.conf file contains
configuration information for the name resolver and should contain the
following:
order hosts, bind multi on
5.
This configuration tells the name
resolver to check the /etc/hosts file before attempting to query a nameserver
and to return all valid addresses for a host found in the /etc/hosts file
instead of just the first.
6.
The /etc/hosts file contains the names
of all the computers on the local network.
7.
For a small network, maintaining this
file is not difficult, but for a large network keeping the file up to date is
often impractical.
The /etc/resolv.conf file provides information
about name servers
employed to resolve hostnames.
[root@main~]# cat /etc/resolv.conf
search rcn.com
nameserver 192.168.2.1