Networking - Ethernet setup

To setup Ethernet

To install an Ethernet card, we can use the following commands,

[root@localhost root]# neat

[root@localhost root]# setup

[root@localhost root]# redhat-config-network

[root@localhost root]# netconfig

If we have many Ethernet (NIC) cards in the system then Linux gives the alias name of first Ethernet card as "eth0" next "eth1", and so on.

The three methods of network IP address configuration are,

I DHCP

II BOOTP

III STATIC

First two are got the IP address dynamically from the server and static IP address, got by the administrator.

After changing the IP address, we should execute the following commands.

IP Address

All IP addresses are written in dotted decimal notation, with one byte (eight bits) between each dot. A dotted decimal IP address looks like this:

192.168.100.25

Because each number is described by one byte, and because each byte is 8 bits (or binary 1s and 0s), each number can have a value of anything from 0 to 255. Because of 4 numbers with 8 bit, the total address space is said to be 32 bits long (4´8=32). With a 32-bit address space that can handle four billion addresses.

Address blocks come in three sizes, based on the three classes of address.

1. Class A Addresses – Class A addresses provide 16 million IP addresses per network. It uses 24 of the 32 bits in the address space read left to right. This class address looks like this:

X.0.0.0

This number represented by the X is one fixed number from 0 to 126 and always begins with binary 0. This number is used as the first number before the leftmost dot by all the IP addresses in a Class A address space.

2. Class B Addresses – Class B addresses has a total of 65,536 IP addresses per network. This class address looks like this:

X.X.0.0

All Class B addresses begin with a binary 10.

3. Class C Addresses – The smallest increment of IP addresses available to an organization is Class C. In a Class C network, only the rightmost dotted decimal number can be used for a total of 256 IP addresses. All Class C addresses begin with a binary 110. This class address looks like this:

X.X.X.0

To Start Network Service

[root@localhost root]# service network start

Setting network parameters: [ OK ]

Bringing up loopback interface: [ OK ]

Bringing up interface eth0: [ OK ]

ð It stats the Network service and sets Ethernet's IP address.

ifconfig is used to configure the kernel-resident network interfaces.

[root@localhost root]# ifconfig

eth0 Link encap:Ethernet HWaddr 00:16:76:1E:6A:60

inet addr:192.187.10.2 Bcast:192.187.10.255 Mask:255.255.255.0

inet6 addr: fe80::216:76ff:fe1e:6a60/64 Scope:Link

UP BROADCAST MULTICAST MTU:1500 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 txqueuelen:1000

RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

Interrupt:12 Base address:0xde00

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:1053 errors:0 dropped:0 overruns:0 frame:0

TX packets:1053 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:975678 (952.8 Kb) TX bytes:975678 (952.8 Kb)

ð It shows all the information of Ethernet.

PING Command

[root@localhost root]# ping 192.168.10.255 -b

ð It shows which computer or computers are networked with your computer. Ping always sends a message to all other computers in network by ICMP protocol (Internet Control Message Process). You can give a particular IP address for checking, Ex.

[root@localhost root]# ping 192.168.10.15

ð If the computer is connected along with your system then ping informs you by sending messages to that system and taking messages from that system.

To setup a virtual IP address we should use ifconfig command.

To set Virtual IP Address

[root@localhost root]# ifconfig eth0:192.168.10.50

ð When you will give the command of ifconfig then the system will show the virtual IP address, but when restart the network service, again it will change and will set permanent IP address.

To Disable or Enable Ethernet

You can disable any particular Ethernet by giving ifdown command. Consider in following example, we will disable the eth0 Ethernet,

[root@localhost root]# ifdown eth0

And again to enable the eth0, we have to give another command ifup.

[root@localhost root]# ifup eth0

To Set Virtual Hostname

[root@localhost root]# hostname

ð It shows current system’ hostname.

[root@localhost root]# hostname

ð It changes the hostname. It will affect after logout and login. But when you will restart the computer then old hostname again will set to hostname. If you want to set an IP address permanently then you should change network file which is in “/etc/sysconfig” directory. Such that,

[root@localhost root]# vi /etc/sysconfig/network

NETWORK = yes

HOSTNAME = localhost.com

NISDOMAIN = localhost.com

ð After putting new name in HOSTNAME, we must restart the Network service. Such as.

[root@localhost root]# service network restart

ð After restarting the Network service, if still old hostname is not changed then we have to edit another file which is given below,

[root@localhost root]# vi /etc/sysconfig/network/eth0