In CentOS, how does one modify the network connection configuration?

Source: Internet
Author: User
Tags centos nameserver

Recently, I have been tossing the CentOS6.4 server configuration, and I have been configuring LNMP + Django on the server.
Although I have been using MAC for development, the configuration in CentOS/RHEL for the first time still needs to be investigated.

1. Use the editor to open the Nic configuration file. eth0 is used by default.

The code is as follows: Copy code

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

Enter the following content

The code is as follows: Copy code

DEVICE = eth0 # describe the DEVICE alias for the NIC, for example, it is eth0 in the ifcfg-eth0 file
ONBOOT = yes # enable or not at startup. CentOS is disabled by default.
BOOTPROTO = static # set it to static configuration. dhcp or bootp is optional when you need to obtain the ip address dynamically.
HWADDR = 00: 06: E3: 0F: 62: EF # hardware MAC address of the NIC
IPADDR = 192.168.0.100 # IP address
BROADCAST = 192.168.0.255 # corresponding subnet BROADCAST address
NETMASK = 255.255.255.0 # subnet mask
NETWORK = 192.168.0.0 # NETWORK address
GATEWAY = 192.168.0.1 # GATEWAY address, which can be set
DNS1 = 8.8.8.8 # Main DNS, optional
DNS2 = 8.8.4.4 # backup DNS, optional
IPV6INIT = no # IPv6 related
IPV6_AUTOCONF = no # IPv6 related


2. Modify DNS resolution and edit the resolv. conf file.

The code is as follows: Copy code

Vi/etc/resolv. conf

Type

Nameserver 8.8.8.8
Nameserver 8.8.4.4

3. Restart the network configuration

The code is as follows: Copy code

Service network restart

4. Enable or disable the network

The code is as follows: Copy code

Ifup eth0 # open the network
Ifconfig eth0 up # open the network
 
Ifdown eth0 # Disable the network
Ifconfig eth0 down # Disable the network

5. Configure the network service

The code is as follows: Copy code

Vi/etc/sysconfig/network

Type

The code is as follows: Copy code

NETWORKING = yes # enable the network service
HOSTNAME = centos # host name
GATEWAY = 192.168.0.1 # GATEWAY settings

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.