Detailed explanation of centos Nic configuration under the VPs server ......

Source: Internet
Author: User
Tags vps nameserver vps server

Enable Nic automatically
After centos 6.x is installed, You need to manually activate the NIC every time you start the system. The following methods can be used to automatically activate the NIC after the system starts.
CAT/etc/sysconfig/network-scripts/ifcfg-eth0

Device = "eth0"
Hwaddr = "00: 0C: 29: FC: 1c: 72"
Nm_controlled = "yes"
Onboot = "no"

Change onboot to Yes
VI/etc/sysconfig/network-scripts/ifcfg-eth0

Device = "eth0"
Hwaddr = "00: 0C: 29: FC: 1c: 72"
Nm_controlled = "yes"
Onboot = "yes"

# Service network restart

Basic configuration after centos 6 is installed

1. Network Configuration
(1) command configuration
# Ifconfig eth0 192.168.0.2 netmask 255.255.255.0 // ip address, subnet mask
# Route add default GW 192.168.0.1 Dev eth0 // Gateway
# Hostname centos // computer name
(2) file configuration
Modify IP Address
Modify the configuration file of the IP address of the corresponding NIC (the following gateway address, IP address, and subnet mask are network addresses not local LAN addresses)
# Vi/etc/sysconfig/network-scripts/ifcfg-eth0
Device = eth0 (describe the device alias for the NIC, for example, it is eth0 in the ifcfg-eth0 file)
Bootproto = static, IP addresses obtained through the BOOTP protocol)
Broadcast = 192.168.0.255 (corresponding subnet broadcast address)
Hwaddr = 00: 07: E9: 05: E8: B4 (corresponding Nic physical address)
Ipaddr = 12.168.1.2 (if the IP address obtained by the NIC is set to static, the IP address corresponding to the NIC is specified in this field)
Ipv6init = No (enable or disable IPv6; Disable No, enable yes)
Ipv6_autoconf = No (enable or disable automatic IPv6 Configuration; Disable No, enable yes)
Netmask = 255.255.255.0 (network mask corresponding to the NIC)
Network = 192.168.1.0 (network address corresponding to the NIC)
Onboot = Yes (whether to set this network interface when the system starts. If it is set to yes, the device is activated when the system starts)

Modify Gateway
Modify the gateway configuration file of the corresponding Nic
# Vi/etc/sysconfig/Network
Networking = Yes (indicates whether the system uses the network, which is generally set to yes. If it is set to no, the network cannot be used, and many system service programs cannot be started)
Hostname = centos (set the Host Name of the local machine. The host name set here must correspond 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)

Modify DNS
Modify the DNS configuration file of the corresponding Nic
# Vi/etc/resolv. conf
Nameserver 202.101.224.68 (Domain Name Server)
Nameserver 202.101.224.69 (Domain Name Server)

Restart Network Configuration
# Service network restart
Or
#/Etc/init. d/network restart

The server uses Sun's virtualbox to install centos. when accessing the internet, the 'connect: network is unreachable error' problem occurs. virtualbox uses the bridged adapter Method for connection.

By modifying the/etc/sysconfig/network-scripts/ifcfg-eth0, the IP address of the virtual machine is already network and netmask.
Ping the same network and netmask, soIt is determined that it should be the routing configuration problem of the virtual machine operating system.Attempt to directly modify the system file/Etc/sysconfig/network-scripts/route-eth0 add 'defult via 192.168.0.1 ′(192.168.0.1 is mine.Router gateway address).
I ran to the/etc/sysconfig/network-scripts/directory and found that the root node didn't have the route-eth0 file, so I created a file and added 'defult via 192.168.0.1 'to the file.
Run '/etc/init. d/network restart' to restart the network. Everything is OK! It turns out that the problem lies in the routing.
In fact, I have already used the "following" route add command to configure the routing gateway, but it becomes invalid after the restart, which is a little careless.

# Route add default GW 192.168.0.1 Dev eth0 // Gateway
Here, the first part of the router gateway is the network address.

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.