RHEL6- (8) IP ASSIGN/CHANGE
HOW TO ASSIGN/CHANGE THE
IP ADDRESS:
[root@rhel6-server ~]# ifconfig -a
eth0
Link encap:Ethernet HWaddr
00:0C:29:80:4E:36
inet6 addr: fe80::20c:29ff:fe80:4e36/64 Scope:Link
UP BROADCAST RUNNING MULTICAST
MTU:1500 Metric:1
RX packets:11151 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1039262 (1014.9 KiB) TX
bytes:468 (468.0 b)
Interface “eth0” has no IP. First we will
assign an IP to it then we will change it,
We know that the interface config file
resides under,
/etc/sysconfig/network-scripts/
[root@rhel6-server
network-scripts]# cat ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:80:4E:36
TYPE=Ethernet
UUID=fd01976e-0dfd-4228-a8ad-3a31e481cef5
ONBOOT=no
NM_CONTROLLED=yes
BOOTPROTO=dhcp
We need to edit the file related to
corresponding interface.
Here interface is “eth0” and corresponding
file is “ifcfg-eth0”
Better to replace this file with any working
interface.
[root@rhel6-server
network-scripts]# cp ifcfg-eth3 ifcfg-eth0
cp: overwrite `ifcfg-eth0'? y
[root@rhel6-server network-scripts]# vi
ifcfg-eth0
DEVICE=eth3
TYPE=Ethernet
UUID=aff36e84-11b8-4d37-8243-79ba0798839f
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
HWADDR=00:0C:29:80:4E:54
IPADDR=192.168.110.135
PREFIX=24
GATEWAY=192.168.234.2
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth3"
Now we need to modify the values.
Well, I overwrite the File and now it is
asking for UUID…LLL
Ok… no issues. First of all, UUID and NM_CONTROLLED
parameters are not required to operate the interface, they can be ignored.
But if you are eager to supply UUID then,
[root@rhel6-server ~]# uuidgen
eth0
0efaf760-cf38-4593-bd5f-59e1642cbb0e
[root@rhel6-server
network-scripts]# vi ifcfg-eth0
DEVICE=eth0 çChanged
TYPE=Ethernet
UUID=0efaf760-cf38-4593-bd5f-59e1642cbb0e çChanged
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
HWADDR=00:0C:29:80:4E:36 çChanged
IPADDR=192.168.110.137 çChanged
PREFIX=24
GATEWAY=192.168.110.1 çChanged
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0" çChanged
[root@rhel6-server /]# service
network restart
Shutting down interface eth0: Device state: 3 (disconnected)
[ OK ]
Shutting down interface eth1: Device state: 3 (disconnected)
[ OK ]
Shutting down interface eth2: Device state: 3 (disconnected)
[ OK ]
Shutting down interface eth3: Device state: 3 (disconnected)
[ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Active connection state: activated
Active connection path:
/org/freedesktop/NetworkManager/ActiveConnection/10
[ OK ]
Bringing up interface eth1: Active connection state: activated
Active connection path:
/org/freedesktop/NetworkManager/ActiveConnection/11
[ OK ]
Bringing up interface eth2: Active connection state: activated
Active connection path:
/org/freedesktop/NetworkManager/ActiveConnection/12
[ OK ]
Bringing up interface eth3: Active connection state: activated
Active connection path:
/org/freedesktop/NetworkManager/ActiveConnection/13
[ OK ]
[root@rhel6-server ~]# ifconfig
eth0
eth0
Link encap:Ethernet HWaddr
00:0C:29:80:4E:36
inet addr:192.168.110.137
Bcast:192.168.110.255
Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe80:4e36/64 Scope:Link
UP BROADCAST RUNNING MULTICAST
MTU:1500 Metric:1
RX packets:11180 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1042237 (1017.8 KiB) TX
bytes:468 (468.0 b)
Make this entry in to /etc/hosts also,
[root@rhel6-server ~]# cat
/etc/hosts
#127.0.0.1
localhost
192.168.234.146 rhel6-server
#192.168.234.147 rhel6-server
192.168.110.135 rhel6-server
192.168.110.137 rhel6-server çç
TEMPORARY CHANGE:
[root@rhel6-server ~]# ifconfig
eth0 192.168.234.192 netmask 255.255.255.0 broadcast 192.168.234.255
In the above command, 192.168.234.192 is machine's
IP address, 255.255.255.0 is the netmask and 192.168.234.255 is broadcast
address.
The ifconfig command does not store these
changes permanently. Upon reboot this information is lost.
[root@rhel6-server ~]# ifconfig
eth0
eth0
Link encap:Ethernet HWaddr
00:0C:29:80:4E:36
inet addr:192.168.234.192
Bcast:192.168.234.255
Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe80:4e36/64 Scope:Link
UP BROADCAST RUNNING MULTICAST
MTU:1500 Metric:1
RX packets:11344 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1057476 (1.0 MiB) TX
bytes:468 (468.0 b)
Check the changes are effective or not…?
C:\Users\HP>ping 192.168.234.192
Pinging 192.168.234.192 with 32 bytes of
data:
Reply from 192.168.234.192: bytes=32
time=88ms TTL=64
Reply from 192.168.234.192: bytes=32
time=2ms TTL=64
Reply from 192.168.234.192: bytes=32
time=2ms TTL=64
Reply from 192.168.234.192: bytes=32
time=2ms TTL=64
Ping statistics for 192.168.234.192:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in
milli-seconds:
Minimum = 2ms, Maximum = 88ms, Average = 23ms
C:\Users\HP>ping
192.168.110.137
Pinging 192.168.110.137 with 32 bytes of
data:
Reply from 192.168.110.1: Destination host
unreachable.
Ping statistics for 192.168.110.137:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Control-C
^C
No comments:
Post a Comment