Every machine has its own unique hostname and the ipaddress. The ipaddress is similar to the phone number. The human can communicate via phone number. The machines can communicate each other using the ip address. The ip address of the machine must be unique.
How to know the ip address of the machine?
For every machine there must be an Ethernet card for each and every ether net card there are two addresses
- Hardware address or MAC address
- Ip address
The hardware address or mac address is permanent to the every device, but the ip address of the device is dynamic it varies from network to network. Of course we can obtain the static ipaddress to the system by some method I will discuss that later.
The ip address can be seen as follows by using ifconfig command.
[root@sys2 ~]# ifconfig -a
eth2 Link encap:Ethernet HWaddr 00:0C:29:F2:03:74
inet addr:192.168.1.6 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fd75:f6de:16de:0:20c:29ff:fef2:374/64 Scope:Global
inet6 addr: fe80::20c:29ff:fef2:374/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11378 errors:0 dropped:0 overruns:0 frame:0
TX packets:191 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:1015936 (992.1 KiB) TX bytes:23851 (23.2 KiB)
eth2 Link encap:Ethernet HWaddr 00:0C:29:F2:03:74
inet addr:192.168.1.6 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fd75:f6de:16de:0:20c:29ff:fef2:374/64 Scope:Global
inet6 addr: fe80::20c:29ff:fef2:374/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11378 errors:0 dropped:0 overruns:0 frame:0
TX packets:191 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:1015936 (992.1 KiB) TX bytes:23851 (23.2 KiB)
In the above output the highlighted portion is the ip address of the Ethernet card eth2.
How to change the ipaddress of eth2?
By using the command # ifconfig eth2 192.168.1.8 up
The above command will assign 192.168.1.8 to the eth2 card temporarily
[root@sys2 ~]# ifconfig eth2 192.168.1.8 up
[root@sys2 ~]# ifconfig
eth2 Link encap:Ethernet HWaddr 00:0C:29:F2:03:74
inet addr:192.168.1.8 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fd75:f6de:16de:0:20c:29ff:fef2:374/64 Scope:Global
inet6 addr: fe80::20c:29ff:fef2:374/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11516 errors:0 dropped:0 overruns:0 frame:0
TX packets:224 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:1029332 (1005.2 KiB) TX bytes:30398 (29.6 KiB)
[root@sys2 ~]# ifconfig
eth2 Link encap:Ethernet HWaddr 00:0C:29:F2:03:74
inet addr:192.168.1.8 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fd75:f6de:16de:0:20c:29ff:fef2:374/64 Scope:Global
inet6 addr: fe80::20c:29ff:fef2:374/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11516 errors:0 dropped:0 overruns:0 frame:0
TX packets:224 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:1029332 (1005.2 KiB) TX bytes:30398 (29.6 KiB)
From the above out put the ipaddress is changed success fully.
For changing the ipaddress permanently edit the file /etc/sysconfig/network-scripts/ifcfg-eth2 as follows.
[root@sys2 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth2
(original file)
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
DEVICE =eth2
BOOTPROTO =none
NETMASK =255.255.255.0
TYPE =Ethernet
HWADDR =00:0c:29:f2:03:74
IPADDR =192.168.1.6
(Edited file)
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
DEVICE =eth2
BOOTPROTO =none
NETMASK =255.255.255.0
TYPE =Ethernet
HWADDR =00:0c:29:f2:03:74
IPADDR =192.168.1.8
(original file)
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
DEVICE =eth2
BOOTPROTO =none
NETMASK =255.255.255.0
TYPE =Ethernet
HWADDR =00:0c:29:f2:03:74
IPADDR =192.168.1.6
(Edited file)
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
DEVICE =eth2
BOOTPROTO =none
NETMASK =255.255.255.0
TYPE =Ethernet
HWADDR =00:0c:29:f2:03:74
IPADDR =192.168.1.8
Write an the quit the file to change the ip address permenantly.
Then restart the service as follows
[root@sys2 ~]# service network restart
Shutting down interface eth2: Device state: 3 (disconnected)[ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0:Error: No suitable device found: no device found for connection 'System eth0'.[FAILED]
Bringing up interface eth2: Active connection state: activated
Active connection path : /org/freedesktop/NetworkManager/
ActiveConnection/6 [ OK ]
Shutting down interface eth2: Device state: 3 (disconnected)[ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0:Error: No suitable device found: no device found for connection 'System eth0'.[FAILED]
Bringing up interface eth2: Active connection state: activated
Active connection path : /org/freedesktop/NetworkManager/
ActiveConnection/6 [ OK ]
What is logical ip address virtual ipaddress and how to configure that on an Ethernet card?
- If the network card has more than one ipaddress those are called logical or virtual ipaddress.
- Configuring the logical ipaddress temporarily
By using the following commands we can obtain multiple ip addresses to the single network card.
[root@sys2 ~]# ifconfig eth2:0 192.168.1.6 up
[root@sys2 ~]# ifconfig eth2:0 192.168.1.7 up
[root@sys2 ~]# ifconfig eth2:0 192.168.1.8 up
SIOCSIFADDR : File exists
SIOCSIFFLAGS: Cannot assign requested address
SIOCSIFFLAGS: Cannot assign requested address
[root@sys2 ~]# ifconfig eth2:0 192.168.1.9 up
[root@sys2 ~]# ifconfig eth2:0 192.168.1.7 up
[root@sys2 ~]# ifconfig eth2:0 192.168.1.8 up
SIOCSIFADDR : File exists
SIOCSIFFLAGS: Cannot assign requested address
SIOCSIFFLAGS: Cannot assign requested address
[root@sys2 ~]# ifconfig eth2:0 192.168.1.9 up
- Configuring the logical ipaddress permanently.
Make the copies of the scripts as follows
[root@sys2 ~]# cd /etc/sysconfig/network-scripts/
[root@sys2 network-scripts]# cp ifcfg-eth2 ifcfg-eth2:0
[root@sys2 network-scripts]# cp ifcfg-eth2 ifcfg-eth2:1
[root@sys2 network-scripts]# cp ifcfg-eth2 ifcfg-eth2:2
[root@sys2 network-scripts]# cp ifcfg-eth2 ifcfg-eth2:0
[root@sys2 network-scripts]# cp ifcfg-eth2 ifcfg-eth2:1
[root@sys2 network-scripts]# cp ifcfg-eth2 ifcfg-eth2:2
- Edit the every script with respect to their ip address
[root@sys2 network-scripts]# vim ifcfg-eth2:0
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
DEVICE =eth2
BOOTPROTO =none
NETMASK =255.255.255.0
TYPE =Ethernet
HWADDR =00:0c:29:f2:03:74
IPADDR =192.168.1.6 [root@sys2 network-scripts]# vim ifcfg-eth2:1
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
DEVICE =eth2
BOOTPROTO =none
NETMASK =255.255.255.0
TYPE =Ethernet
HWADDR =00:0c:29:f2:03:74
IPADDR =192.168.1.7
[root@sys2 network-scripts]# vim ifcfg-eth2:2
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
DEVICE =eth2
BOOTPROTO =none
NETMASK =255.255.255.0
TYPE =Ethernet
HWADDR =00:0c:29:f2:03:74
IPADDR =192.168.1.9
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
DEVICE =eth2
BOOTPROTO =none
NETMASK =255.255.255.0
TYPE =Ethernet
HWADDR =00:0c:29:f2:03:74
IPADDR =192.168.1.6 [root@sys2 network-scripts]# vim ifcfg-eth2:1
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
DEVICE =eth2
BOOTPROTO =none
NETMASK =255.255.255.0
TYPE =Ethernet
HWADDR =00:0c:29:f2:03:74
IPADDR =192.168.1.7
[root@sys2 network-scripts]# vim ifcfg-eth2:2
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
DEVICE =eth2
BOOTPROTO =none
NETMASK =255.255.255.0
TYPE =Ethernet
HWADDR =00:0c:29:f2:03:74
IPADDR =192.168.1.9
0 comments:
Post a Comment