How to set IP in Linux Machine

Add the following Lines to ifcfg-eth0 file as below.

[root@db ~]#vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
HWADDR="08:00:27:67:E4:56"
NM_CONTROLLED="yes"
ONBOOT="Yes"
IPADDR=172.17.174.231
NETWORK=172.17.174.0
NETMASK=255.255.255.0
GETWAY=172.17.174.1
[root@db ~]#

update the host file as well

[root@db ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.17.174.231 db
[root@db ~]#

Restart Network services

[root@db ~]# service network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
[root@db ~]#

Test it

[root@db ~]# ping db
PING db (172.17.174.231) 56(84) bytes of data.
64 bytes from db (172.17.174.231): icmp_seq=1 ttl=64 time=0.371 ms
64 bytes from db (172.17.174.231): icmp_seq=2 ttl=64 time=2.27 ms
^C
Advertisements

About Sher khan

Senior Oracle DBA, Oracle 10g , Oracle 11g OCE ,Oracle 12C and Oracle 11g OPN certified Specialist, OCP Certified in Oracle 9i,10g , 11g and 12C. I am working in Oracle technology since 2004. Currently working in U.A.E Email: sher487@hotmail.com
This entry was posted in Linux commands for DBA. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s