Network configuration related file configuration options in CentOS

Source: Internet
Author: User
Tags nameserver
This article describes how to configure network configuration related files in CentOS. For more information, see CentOS.

CentOS modifies network-related configuration files such as IP addresses

Find the IP address configuration file: ifcfg-eth.
Path:/etc/sysconfig/network-scripts/ifcfg-eth number
Description of configuration items in the file


Copy codeThe code is as follows:
DEVICE = eth0 # describe the DEVICE alias for the NIC, for example, it is eth0 in the ifcfg-eth0 file
BOOTPROTO = static # set the way for the NIC to obtain the IP address. options include static (static), dhcp (using DHCP to obtain the IP address), and bootp (using the BOOTP protocol to obtain the IP address)
BROADCAST = 192.168.0.255 # Subnet BROADCAST address
HWADDR = 00: 17: F3: 05: 18: 20 # Nic physical address (MAC)
IPADDR = 192.168.0.2 # BOOTPROTO = static, use this IP address
IPV6INIT = no # Initialize IPv6 functions
IPV6_AUTOCONF = no # whether to automatically configure IPv6
NETMASK = 255.255.255.0 # network mask corresponding to the network adapter
NETWORK = 192.168.1.0 # NETWORK address of the NIC
ONBOOT = yes # whether to enable the device when the system starts. If yes, the device is activated when the system starts.
# TYPE = Ethernet # network TYPE
# USERCTL = no # whether non-root users can control the device

Updated on August 18, March 18, 2014: Do not set the NETWORK parameter in CentOS. the official website has been deprecated and the Gateway cannot be successfully added after the NETWORK parameter is set. for details, refer to the latest blog post: problems caused by NETWORK settings in CentOS NETWORK configuration.

CentOS help http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-networkscripts-interfaces.html

Configuration files related to CentOS gateway configuration
Path:/etc/sysconfig/network

Description of configuration items in the file


Copy codeThe code is as follows:
NETWORKING = yes # indicates whether the system uses the network, which is generally yes. If no, the network is not used and many system services cannot be started.
# NETWORKING_IPV6 = no # enable IPv6
# FORWARD_IPV4 = no # whether to enable IP forwarding
# HOSTNAME = localhost. localdomain # set the host name of the local machine. The value must correspond to the host name set in/etc/hosts. if it is commented out, the host name or domain name is resolved first, and then DNS is resolved.
GATEWAY = 192.168.1.1 # set the IP address of the GATEWAY
# GATEWAYDEV = gateway # gateway device name

CentOS help http://www.centos.org/docs/5/html/5.2/Deployment_Guide/s2-sysconfig-network.html
 
Configuration files related to CentOS DNS
Path:/etc/resolv. conf

Description of configuration items in the file


Copy codeThe code is as follows:
# The most important thing is nameserver. others can be ignored.
Nameserver 8.8.8.8 # google domain name server
Nameserver 8.8.4.4 # google domain name server
# Search mitchellchu.com www.mitchellchu.com # define the domain name search list
# Domain names ellchu.com # define a local domain name
# Sortlist # Sort the returned domain names

Network Device restart
Service network restart
Or
/Etc/init. d/network restart

IP address modification
Effective immediately:
Ifconfig eth0 192.168.0.2 netmask 255.255.255.0
Effective after network device restart
See/etc/sysconfig/network-scripts/ifcfg-eth number modification

Modify the Default Gateway of the current Gateway
Effective immediately:
Route add default gw 192.168.0.1 dev eth0
It takes effect after the network device is restarted:
See/etc/sysconfig/network configuration.

Modify DNS
See/etc/resolv. conf configuration.
The modification takes effect immediately.

Modify host name
Effective immediately:
Hostname centos1
Restart takes effect:
See/etc/sysconfig/network configuration. Note that the configuration of/etc/hosts is also available here.

CentOS official help for networking: http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-networkscripts.html

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.