How to modify the network settings of CentOS and solve the problem that some commands do not exist

Source: Internet
Author: User
Tags domain name server nameserver


1. CentOS modify the IP address to modify the corresponding Nic IP Address Configuration File # vi/etc/sysconfig/network-scripts/ifcfg-eth0 modify the following content DEVICE = eth0 # description of the network adapter corresponding to the DEVICE alias, for example, in the ifcfg-eth0 file, it is eth0BOOTPROTO = static # Set the way the NIC gets the IP address, the possible option is static, dhcp or bootp, respectively corresponding to the static specified IP address, IP address obtained through dhcp protocol, IP address obtained through bootp protocol BROADCAST = 192.168.0.255 # corresponding subnet BROADCAST address HWADDR = 00: 07: E9: 05: E8: b4 # The physical IP address of the corresponding Nic, IPADDR = 12.168.1.2 # If the IP address obtained by the NIC is set to static, this field specifies the IP address www.2cto.com IPV6INIT = no00006_autoconf = noNETMASK = 255.255.255.0 # NETWORK mask NETWORK = 192.168.1.0 # NETWORK address ONBOOT = yes # whether the system starts set this network interface, when set to yes, the device is activated when the system starts.
2. Modify the gateway of CentOS to modify the configuration file [root @ centos] # vi/etc/sysconfig/network of the gateway of the corresponding Nic modify NETWORKING = yes (indicates whether the system uses the network, it is generally set to yes. If it is set to no, the network cannot be used, and many system service programs cannot start) HOSTNAME = centos (set the Host Name of the local machine, the host name set here corresponds to the host name set in/etc/hosts) GATEWAY = 192.168.1.1 (set the IP address of the GATEWAY connected to the local machine. For example, the gateway is 10.0.0.2)
3. Modify DNS in CentOS to modify the DNS configuration file of the corresponding Nic # vi/etc/resolv. conf modify the following content: nameserver 8.8.8.8 # google Domain Name Server nameserver 8.8.4.4 # google Domain Name Server
4. restart the network configuration # service network restart or www.2cto.com #/etc/init. d/network restart modify IP address effective immediately: # ifconfig eth0 192.168.0.2 netmask 255.255.255.0 start effective: Modify/etc/sysconfig/network-scripts/ifcfg-eth0 modify Gateway Default Gateway effective immediately: # route add default gw 192.168.0.1 dev eth0 start effective: Modify/etc/sysconfig/network modify DNS Modify/etc/resolv. the change of conf takes effect immediately. The change of host name takes effect immediately after startup: # hostname centos1 takes effect immediately after startup:/etc/sysconfig/networkcentos cannot be found The ifconfig command and other commands prompt that some commands do not use #/sbin/ifconfig. The cause is that the default environment variable settings of the system do not execute echo $ PATH under the common user and root user respectively, PATH contains four missing addresses:/sbin:/usr/local/sbin:/usr/kerberos/sbin. ifconfig is exactly in/sbin. You can also open/etc/profile to find that there are no environment variables for/sbin. Run vi/etc/profile and add the following statement at the end of the file: www.2cto.com PATH = $ PATH:/sbin # append the/sbin directory export PATH = $ PATH after the PATH variable: /sbin # Set the variable to save globally and exit. Modify/home/user/. bash_profile and add/sbin:/usr/local/sbin:/usr/kerberos/sbin to the PATH. After the modification, run the command: .. bash_profile. You can also log off or restart it to make the modified content take effect. Then sudo ifconfig, and then OK. Author ljfbest

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.