Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
How To Configure Static IP On CentOS 6
## Configure eth0
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
NAME="System eth0"
## Configure Default Gateway
# vi /etc/sysconfig/network
## Restart Network Interface
/etc/init.d/network restart
## Configure DNS Server
# vi /etc/resolv.conf
nameserver # Replace with your nameserver ip
nameserver # Replace with your nameserver ip

mbadran commented Mar 2, 2013

Nice overview.

You can also run dhclient (once off) to automatically update the /etc/resolv.conf file.

excellent! thanks this was helpful :)



ghost commented Jun 27, 2013

Just downloaded centos 6.4 and was stunned that it does not detect my onboard nic. Thank you so much :)

aklesky commented Jul 21, 2013

Thank you!

deffjay commented Aug 7, 2013

Great, thanks!

ropaolle commented Oct 1, 2013


good reference. :)

Yinette commented Oct 21, 2013

"NETWORKING=yes" Never fails to make me giggle.

bib4311 commented Oct 23, 2013

what is this uuid and how can i find it i am new linux user

thanks in advance for reply

Thanks you very much!

Thanks you very much!

Thanks you very much!

Great stuff, saved me a lot of time!

jgdev commented Dec 30, 2013

Hey, thanks, really ;)

thanks, really

thanks, really

palamrit commented Jan 9, 2014

I don't have eth0 in folder, please suggest I am pasting directory dump

ifcfg-lo ifdown-ppp ifup-ippp ifup-sit
ifdown ifdown-routes ifup-ipv6 ifup-tunnel
ifdown-bnep ifdown-sit ifup-isdn ifup-wireless
ifdown-eth ifdown-tunnel ifup-plip init.ipv6-global
ifdown-ippp ifup ifup-plusb net.hotplug
ifdown-ipv6 ifup-aliases ifup-post network-functions
ifdown-isdn ifup-bnep ifup-ppp network-functions-ipv6
ifdown-post ifup-eth ifup-routes

Please suggest

@palamrit, you should try ifup-eth and ifup-wireless


Great stuff, saved me a lot of time!

Thanks you very much!

Thanks for this stuff

but when i tried to "/etc/sysconfig/network-scripts/ifcfg-eth0" its showing file directory not available.
after that i tried to edit "vi /etc/sysconfig/network/ifcfg-eth0" then its showing access denied but i login from "root".

J-4-DEGS commented Mar 3, 2014

Thank you very much, quite helpful!

I had followed the instructions mentioned but still it's not working, what would be the name server ip address if i m using wireless network(home), i am using wireless network, i tried with both Bridge network and NAT, but no luck, could you please help me...

ralexx commented Mar 23, 2014

Sweet! Thanks

I'm fowlowed you. But I tried ping to I got ping: unknow host Please help me solve problem

Awesome! Thanks

declum commented Apr 24, 2014


I have configured static IP address ( But everytime i boot up, its picking another IP address. (

But after the boot up, if i give "service network restart" it gets changed to my static IP. If the network is not restarted, its with its own ( If i check the ifcfg-eth0 file, i see the IP which i have given.

How to fix it?


nasery commented May 10, 2014

how to change linux centose ip address

unikhil commented Jul 4, 2014

Hi Clement,

I have similar problem , everytime I reboot its pickingip another IP. Is your problem resolved? have you found reason?


keshara commented Jul 19, 2014

Check below link if someone still have issues with static ip on centos 6.

zrajm commented Mar 23, 2015

Based on a Redhat network config, I simply added the DNS by adding the following extra lines to /etc/sysconfig/network-scripts/ifcfg-eth0. Then after restarting the network I already had the correct values in /etc/resolv.conf.


kakheo commented Mar 23, 2015

Thank you!

Hey declum/unikhil,

I had the same issue but managed to resolve it. The service NetworkManager appears to override any configurations made in /etc/sysconfig/network-scripts. A couple of remedies:

  1. Add the line NM_CONTROLLED=no to the config file.... or

  2. Disable network manager by

systemctl stop NetworkManager.service systemctl disable NetworkManager.service


Thanks! Need to create my own note :)

Thanks! Helped a lot.

Thank you so much.

Great! Thanks for share!


it's work confirm!!!!


DougSr commented Apr 4, 2016

Wow you don't know how much I did battle with a broken set-up because of bad advice.
Because of this write-up it now works beautifully.
Thank you!


I must say when I started configuring static IP's on Cent OS 7 via CLI it was pretty confusing, but then i understood it - it became much easier. Without need to disable Network Manager, just type this command “nmtui” to open Network manager and edit any connection. This is super easy and no VI , NANO are needed. Plus can reset adapter too. Hope this will help others as well. Regards!

Thanks, It's helpful to me.

How about /etc/hosts file which has reference to server along with alias?

@azhung I had the same issue but fixed it by adding the line GATEWAY= (Replacing with your correct gateway, of course) to /etc/sysconfig/network-scripts/ifcfg-eth0

@fernandoaleman @azhung

Can't figure it out. Seems to have a problem setting the IP. I'm trying to set it to

$ ping
connect: Network is unreachable

$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
        ether [snipped] txqueuelen 1000 (Ethernet)
        RX packets 23993 bytes 1768614 (1.6MiB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 2243 bytes 634063 (619.2 KiB)
        TX errors 0 dropped 0 overrun 0 carrier 0 collisions 0
        device interrupt 20 memory 0xf7c00000-f7c20000
lo: [snipped: irrelevant]

wellington1993 commented Sep 5, 2016

Thanks! Lower is better!

Thank you

Thank you. :-)


Muchas gracias - been using this for a long time as reference for static IP. Rock on!

Thank you very much!

thank you..

Thank you so much 👍 :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment