Comments on Linux Basics - Set A Static IP On CentOS

Linux Basics - Set A Static IP On CentOS This tutorial explains the configuration of a static IP address (IPv4 and IPv6), the hostname and nameservers on CentOS. To be compatible with Desktop and Server Systems, we do the configuration on the shell.

8 Comment(s)

Add comment

Please register in our forum first to comment.

Comments

By: Luke Hamiltn

In step 2, you wanted to make a backup with the following command: 

mv  /etc/sysconfig/network-scripts/ifcfg-eth0  /etc/sysconfig/network-scripts/ifcfg-eth0.bak

However, you should have used "cp" instead of "mv".  "mv" will rename the original file instead of creating a backup of the original.  Use the folliwng instead:

cp  /etc/sysconfig/network-scripts/ifcfg-eth0  /etc/sysconfig/network-scripts/ifcfg-eth0.bak

By: dongchao

yes,you are absolutely right !but i am still wondering how can i set the specific ip address as well as the gateway address to be compatible with my environment.because of this problem i have already been haunted for  a whole day.can you help me ? thanks a lot !

By: Der PCFreak

In CentOS 7 there is a tool called "nmtui" it is installed by default, even in the minimum installation. It is a text-based "graphical" tool where setting up networking is very easy and straightforward. I would only use the manual way if I want to script or automate networking setup and use "nmtui" wherever possible.

By: david

I'd suggest that you rename your copied file differently. The init scripts look for anything with "ifcfg-" and process it as a valid interface, so if you name the file OLD.ifcfg-eth0 instead, this will work cleaner.

By: Fabio

Are you sure that:"NETWORKING=yes HOSTNAME=server1.example.com GATEWAY=192.168.0.1"

has to be add in "/etc/resolv.conf" and not in "/etc/sysconfig/network"?

By: mohammad shamim khan

Hi team,

 

[[email protected] // /]# service network restartfgrep: ifcfg-ifcfg-: No such file or directoryfgrep: ifcfg-ifcfg-: No such file or directory/etc/init.d/network: line 207: ./ifcfg-ifcfg-: No such file or directoryShutting down loopback interface:                          [  OK  ]Bringing up loopback interface:                            [  OK  ]Bringing up interface eth0:  Device eth0 does not seem to be present, delaying initialization.                                                           [FAILED]fgrep: ifcfg-ifcfg-: No such file or directoryfgrep: ifcfg-ifcfg-: No such file or directoryfgrep: ifcfg-ifcfg-: No such file or directoryegrep: ifcfg-ifcfg-: No such file or directoryBringing up interface ifcfg-:  Device does not seem to be present, delaying initialization.                                                           [FAILED][[email protected] // /]#

please help for the same

By: Hitman47s1

Hello , i follow this steps and i create an other ip adress but when run with it a game server , it run normaly but can't connet to the server so i understand that this new ip not connected to enternet not like the defolt ip !

By: ITnavigator

This is not /etc/resolc.conf file, this it /etc/sysconfig/network:

NETWORKING=yes HOSTNAME=server1.example.com GATEWAY=192.168.0.1 [...]