Configure the IP address for the virtual machine CentOS

Source: Internet
Author: User

The CentOS virtual machine we installed in minimal is not directly connected to the Internet, and it needs to be configured with an IP address. There are two ways to configure IP, one is to use the DHCP service to dynamically obtain an IP address, and the other is to manually configure a static IP address. Either way, first make sure that VMware has the DHCP service turned on.

On the local host desktop, right-click My Computer, select Manage, select services and Applications, double-click Open Services to turn on the virtual machine related services.

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/8B/44/wKioL1hI5M2gDmYLAAAvhcAstNM946.png-wh_500x0-wm_3 -wmp_4-s_4184613718.png "style=" Float:none; "title=" 1.png "alt=" Wkiol1hi5m2gdmylaaavhcastnm946.png-wh_50 "/>

Open the virtual machine and log in to the system as the root user. Use Ifconfig-a to view IP address information for all network cards in the system. Eth0 now has no IP address.

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/8B/47/wKiom1hI5M6QzJDGAAEWqVugxsU421.png-wh_500x0-wm_3 -wmp_4-s_2861508770.png "style=" Float:none; "title=" 2.png "alt=" Wkiom1hi5m6qzjdgaaewqvugxsu421.png-wh_50 "/>

The first way: Use the DHCP service to dynamically obtain an IP address.

# dhclient

# ifconfig-a

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/8B/47/wKiom1hI5M6xJKXkAAEadOlpIiE612.png-wh_500x0-wm_3 -wmp_4-s_2011049560.png "style=" Float:none; "title=" 3.png "alt=" Wkiom1hi5m6xjkxkaaeadolpiie612.png-wh_50 "/>

As you can see, now Eth0 has automatically acquired an IP address of 192.168.147.131.

Test the IP address for access to the extranet: Ping www.baidu.com

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/8B/44/wKioL1hI5M_xD7_lAAEOc2pLUQM936.png-wh_500x0-wm_3 -wmp_4-s_2484311643.png "style=" Float:none; "title=" 4.png "alt=" Wkiol1hi5m_xd7_laaeoc2pluqm936.png-wh_50 "/>

Visible auto-assigned IP addresses can be used.

The second way: Manually configure the static IP address.

To open the Eth0 configuration file using the VI Editor:

# Vi/etc/sysconfig/network-scripts/ifcfg-eth0

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/8B/44/wKioL1hI5M-TGehxAAEyczESiCw361.png-wh_500x0-wm_3 -wmp_4-s_3107202820.png "style=" Float:none; "title=" 5.png "alt=" Wkiol1hi5m-tgehxaaeyczesicw361.png-wh_50 "/>

Press "I" key to enter VI edit mode.

Change the Onboot parameter to "yes" to start the boot.

The Bootproto parameter indicates the way to get the IP, because we used DHCP to obtain the IP, so here is the "DHCP". Next, change it to "static" and configure the IP using manual mode. Add the following lines of information at the end of the configuration file:

ipaddr=192.168.147.131 (IP address to assign)

netmask=255.255.255.0 (Subnet mask)

gateway=192.168.147.2 (gateway address, usually referred to as the Router address)

dns1=192.168.147.2 (DNS address, default is gateway address)

dns2=8.8.8.8 (Alternate DNS address, here is Google's DNS server address)

Exit VI Editor:

Press ESC, and then enter ": Wq" to save the exit

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/8B/47/wKiom1hI5NDhipYMAADusQzId5s555.png-wh_500x0-wm_3 -wmp_4-s_456538508.png "style=" Float:none; "title=" 6.png "alt=" Wkiom1hi5ndhipymaadusqzid5s555.png-wh_50 "/>

The network service needs to be restarted after manually configuring the IP.

# Service Network Restart

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/8B/47/wKiom1hI5NHjH-XqAADl3kcqXWA373.png-wh_500x0-wm_3 -wmp_4-s_27777047.png "style=" Float:none; "title=" 7.png "alt=" Wkiom1hi5nhjh-xqaadl3kcqxwa373.png-wh_50 "/>

Use Ifconfig-a to see if the configuration was successful.

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/8B/44/wKioL1hI5NGA56weAAEf1-pm6Vg943.png-wh_500x0-wm_3 -wmp_4-s_2200624662.png "style=" Float:none; "title=" 8.png "alt=" Wkiol1hi5nga56weaaef1-pm6vg943.png-wh_50 "/>

Test the IP address for access to the extranet: Ping www.baidu.com

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/8B/44/wKioL1hI5NHBamRoAAESHj-kEJY409.png-wh_500x0-wm_3 -wmp_4-s_514399273.png "style=" Float:none; "title=" 9.png "alt=" Wkiol1hi5nhbamroaaeshj-kejy409.png-wh_50 "/>

Now your virtual machine is ready to surf the internet! Have fun!


Configure the IP address for the virtual machine CentOS

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.