Configure IP addresses in CentOS 6.7

Source: Internet
Author: User

Configure IP addresses in CentOS 6.7

1) Use ifconfig-a to view all Nic interfaces on CentOS. At this time, we can see that there are two NICs, one is eth0, which is the real address of Our NIC. At this time, it is not enabled, and there is no IP address, it cannot communicate with the outside world; the other is lo, which is the loopback address.

2) because my current CentOS system is connected to the vro, you can obtain the IP address through the vro. You can use the dhclient command to obtain the IP address so that the CentOS system can communicate online. Then, run the ifconfig command to view the obtained IP address information. Then, pingwww.163.com can be used for normal communication, indicating that CentOS can communicate online.

3) since our CentOS system is used as a server, we generally use a static IP address. Therefore, we need to manually set the IP address. To change the IP address, we need to modify a configuration file, here is the modification of/etc/sysconfig/network-scripts/ifcfg-eth0 (the name of the first Nic of the device is ifcfg-eth0, if there is a second block called ifcfg-eth1, and so on) through vi/etc/sysconfig/network-scripts/ifcfg-eth0 we can see that the current configuration file has the following information:

DEVICE = eth0 ....................................................................... Device Name

HWADDR = 00: 0C: 29: B3: 7B: 7D ............................ The hardware address, that is, the MAC address.

TYPE = Ethernet ............................................................... Network type, Ethernet

UUID = 618cdc88-b304-4b24-af0d-24816f80943a ......................... Universal unique identifier code

ONBOOT = no ............................. Whether to enable this Nic when the system starts

NM_CONTROLLED = yes ....... Whether the device eth0 can be managed by the Network Manager graphical management tool

BOOTPROTO = dhcp ........................... Whether the startup protocol is dhcp or static allocation

To manually configure the IP address, we need to move BOOTPROTO = none (static), and ONBOOT = yes, move the cursor to the last line, press O to enter the editing mode, and add the following information:

IPADDR = 192.168.1.115 ................................................ IP address

NETMASK = 255.255.255.0 ................................................. Subnet Mask

GATEWAY = 192.168.1.1 ...................................................... Default Gateway

DNS1 = 192.168.1.1 ............................................................ DNS Server

DNS2 = 8.8.8.8

Press Esc to exit the editing mode, press shift and: keyboard, and enter wq to exit. Restart the network service network restart and use ifconfig-a to view the NIC information. Ifupeth0 enables the eth0 Nic, and ifdown eth0 disables the eth0 Nic.

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.