This article mainly introduces the CentOS virtual machine need to quickly configure IP network, if the virtual machine direct access to the Internet is very simple, if it is connected with the host need bridge link, specific as follows:
If it's just a virtual machine that needs to be online, it's easy.
1. Enter the CentOS system to view the network configuration.
Enter command: ifconfig-a
2. Enter the Ifcfg-eth0 file.
Enter command: Vim/etc/sysconfig/network-scripts/ifcfg-eth0
Note: The non-root account must be sudo, otherwise it is not authorized to edit, or direct su switch to root user.
3. Configure dynamic IP.
Configure the IP address by modifying the Ifcfg-eth0 content;
Change Onboot=no to Onboot=yes to activate the network card.
4. Restart Network services to view dynamic IP configuration results.
Input command: Service network restart (Restart Network Service)
Note: The root user will still be used
If you want to communicate with each other between the virtual machine and the host, you need to configure the bridging mode
1. Stop virtual machine,virtualbox-> regular-> network
Change the connection mode of NIC 1 to: Bridging network card
2. Enter the Ifcfg-eth0 file.
Enter command: Vim/etc/sysconfig/network-scripts/ifcfg-eth0
Note: The non-root account must be sudo, otherwise it is not authorized to edit, or direct su switch to root user.
3. Configure static IP
ipaddr=192.168.1.10 set the IP address of the virtual machine to the host in a network segment, but cannot duplicate the name
netmask=255.255.255.0 Set Subnet mask
gateway=192.168.1.1 Settings Gateway
dns1=140.207.198.6 set DNS (same as host)
Defroute=yes
4. Restart Network services to view dynamic IP configuration results.
Input command: Service network restart (Restart Network Service)
Note: The root user will still be used
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.