Hamidreza Talebi, linux

CentOS network configuration

You can configure network interface by editing configuration files stored in /etc/sysconfig/network-scripts/ directory.

Lets configure the first network interface eth0. Edit the interface configuration file.

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
(if file doesn't exist, create it with name of ifcfg-ethx)

Append/Modify as follows:

For a system using a Static IP Address

DEVICE="eth0" 
BOOTPROTO="none" 
ONBOOT="yes" 
IPADDR="192.168.1.15" 
NETMASK="255.255.255.0" 
GATEWAY="192.168.1.1"

For a system using a DHCP

DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"

Parameter

Description

DEVICE=<name> Name of the physical device
BOOTPROTO=<none|bootp|dhcp> Protocol to use.
none – No boot-time protocol should be used
bootp – The BOOTP protocol should be used
dhcp – The DHCP protocol should be used
ONBOOT=<yes|no> Should the device be activated at boot-time
IPADDR=<address> IP address
GATEWAY=<address> Gateway IP address
NETMASK=<mask> Netmask value
systemctl restart network

then you have to disable and enable interface:
ifdown eth0; ifup eth0

 

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *