In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How to configure network configuration files in CentOS? In view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
CentOS modifies network-related configuration files such as IP addresses
Find the IP address profile of the corresponding network card: ifcfg-eth number.
Path: / etc/sysconfig/network-scripts/ifcfg-eth digit
Description of configuration items in the file
The code is as follows:
DEVICE=eth0 # describes the device alias corresponding to the Nic, for example, it is eth0 in the file of ifcfg-eth0
BOOTPROTO=static # sets how the network card obtains the ip address. The options are: static (static), dhcp (to obtain IP through DHCP) or bootp (to obtain IP using BOOTP protocol)
BROADCAST=192.168.0.255 # Subnet broadcast address
HWADDR=00:17:F3:05:18:20 # Network Card physical address (MAC)
Use this IP address when IPADDR=192.168.0.2 # BOOTPROTO=static
IPV6INIT=no # initialization of IPv6 function
Whether IPV6_AUTOCONF=no # automatically configures IPv6
The network mask for the NETMASK=255.255.255.0 # Nic
NETWORK=192.168.1.0 # Network address corresponding to the Nic
ONBOOT=yes # whether this device is enabled when the system starts, or activated when the system starts up when yes
# TYPE=Ethernet # Network Type
# USERCTL=no # whether non-root users can control the device
Additional update on March 18, 2014: do not set the parameter NETWORK in CentOS, it has been officially deprecated, and there may be a problem that the gateway cannot be successfully added after setting it.
CentOS official 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 the code
The code is as follows:
NETWORKING=yes # indicates whether the system uses a network, usually yes. If no, the network is not used and many system services cannot be started
# NETWORKING_IPV6=no # whether to enable IPv6
# FORWARD_IPV4=no # whether to enable IP forwarding
# HOSTNAME=localhost.localdomain # set the hostname of this machine. The value should correspond to the hostname set in / etc/hosts. When commented out, the hostname or domain name is generally resolved first, and then the DNS is resolved.
GATEWAY=192.168.1.1 # set the IP address of the gateway
# GATEWAYDEV=gateway # Gateway device name
CentOS official help: http://www.centos.org/docs/5/html/5.2/Deployment_Guide/s2-sysconfig-network.html
CentOS DNS-related configuration files
Path: / etc/resolv.conf
Description of configuration items in the file
Copy the code
The 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 search list of domain names
# domain mitchellchu.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
Take effect after restarting the network device
See modification of / etc/sysconfig/network-scripts/ifcfg-eth number
Modify the current gateway Default Gateway
Effective immediately:
Route add default gw 192.168.0.1 dev eth0
Effective after restarting the network device:
See: / etc/sysconfig/network configuration
Modify DNS
See: / etc/resolv.conf configuration
Effective immediately after modification
Modify hostname
Effective immediately:
Hostname centos1
Restart takes effect:
See: / etc/sysconfig/network configuration, note that there is also the configuration of / etc/hosts
This is the answer to the question about how to configure network configuration files in CentOS. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.