1. Get IP address automatically
Virtual machines use bridging mode, which is equivalent to a network connected to a physical machine, and the physical machine network has a DHCP server that automatically assigns IP addresses.
#dhclient Auto Get IP address command
#ifconfig Query System network card information, IP address, MAC address
After assigning to an IP address, ping the IP address with the physical machine and detect if it is ping.
2. Manually set the IP address
If the virtual machine does not acquire IP automatically, it can only be configured manually, as follows:
Input command
#vi/etc/sysconfig/network-scripts/ifcfg-eth0 [Edit the configuration file for the NIC]
Enter the above command after entering, open the configuration file, use the arrow keys to move the cursor to the last line, press the letter key "O", enter the edit mode, input the following content:
ipaddr=192.168.4.10
netmask=255.255.255.0
gateway=192.168.4.1
In addition, the cursor moves to the line "Onboot=no" and changes to Onboot=yes
"Bootproto=dhcp", Change to Bootproto=none
When you're done, press the ESC key in the upper-left corner of the keyboard, enter: Wq in the lower left of the screen, enter to save the configuration file.
The network service needs to be restarted after the command is
#servicenetwork restart
After the network restarts, the IP of eth0 is in effect, use the command #ifconfigeth0 to view
This article is from the "I am the program my biggest" blog, please be sure to keep this source http://skinglzw.blog.51cto.com/10729606/1846740
Linux CentOS IP set NIC settings