[Linux] CentOS Configuration: Modifying Network Connection Settings

Recently, I have been configuring the CentOS 6.4 server, and configuring LNMP+Django on the server. Although I have been using MAC for development, I still need to investigate a lot of information for the first time configuration on CentOS/RHEL.

  1. Open the network card configuration file using an editor, here we use eth0 by default.

vi /etc/sysconfig/network-scripts/ifcfg-eth0

Enter the following content

DEVICE=eth0 # Describes the device alias corresponding to the network card, for example, in the ifcfg-eth0 file, it is eth0
ONBOOT=yes # Whether to enable at startup, CentOS is not enabled by default
BOOTPROTO=static # Set to static configuration, optional dhcp or bootp when dynamic IP is required
HWADDR=00:06:E3:0F:62 # Hardware MAC address of the network card
IPADDR= # IP address
BROADCAST= # Corresponding subnet broadcast address
NETMASK= # Subnet mask
NETWORK= # Network address
GATEWAY= # Gateway address, optional setting
DNS1= # Primary DNS, optional setting
DNS2= # Secondary DNS, optional setting
IPV6INIT=no # IPv6 related
IPV6_AUTOCONF=no # IPv6 related

  1. Modify DNS resolution, edit the resolv.conf file

vi /etc/resolv.conf



  1. Restart network configuration

service network restart

  1. Open or close the network

ifup eth0 # Open the network
ifconfig eth0 up # Open the network

ifdown eth0 # Close the network
ifconfig eth0 down # Close the network

  1. Configure the network service

vi /etc/sysconfig/network


NETWORKING=yes # Open network service
HOSTNAME=centos # Hostname
GATEWAY= # Gateway setting

Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.