Quantcast
Viewing all articles
Browse latest Browse all 12

Red Hat / CentOS network settings edit via command line

Log on as root, change directory to /etc/sysconfig/network-scripts and list all available devices with the following command

cd /etc/sysconfig/network-scripts# ls -la | grep ifcfg-

Sample outputs

-rw-r--r-- 3 root root 244 Oct 15 2010 ifcfg-eth0
-rw-r--r-- 3 root root 141 Oct 15 2010 ifcfg-eth1
-rw-r--r-- 1 root root 254 Oct 13 2010 ifcfg-lo

Find the configuration file corresponding to the NIC for which you want to set a static IP and edit it. In this example I’ll configure a static IP address for eth1 and use the following Internet Protocol Version 4:

# IP address: 192.168.1.10
# Netmask: 255.255.255.0
# Gateway IP: 192.168.1.1
# DNS Server IP # 2: 8.8.8.8
# DNS Server IP # 2: 8.8.4.4

vi ifcfg-eth1

Sample outputs:

# Intel Corporation 82574L Gigabit Network ConnectionDEVICE=eth1HWADDR=00:25:90:0B:A3:E5ONBOOT=noHOTPLUG=noBOOTPROTO=dhcpTYPE=Ethernet


Now set the parameters below according to your settings, sample static ip configuration

# Intel Corporation 82574L Gigabit Network ConnectionDEVICE=eth1

BOOTPROTO=static

DHCPCLASS=

HWADDR=00:25:90:0B:A3:E5

IPADDR=192.168.1.10

NETMASK=255.255.255.0

GATEWAY=192.168.1.1

ONBOOT=yes

 

To setup DNS servers, edit /etc/resolv.conf, enter

To edit How to edit network settings on Red Hat/Cent OS distributions

vi /etc/resolv.conf

Sample configurations:

nameserver 8.8.8.8
nameserver 8.8.4.4

Now save the configuration file and exit the text editor. To apply changes, we need to bring the network interface down and back up, type the following command:

/etc/init.d/network restart

Or,

service network restart

The post Red Hat / CentOS network settings edit via command line appeared first on Byte Miner.


Viewing all articles
Browse latest Browse all 12

Trending Articles