1. Check the network
# ifconfig
It is found that the network has not been configured yet and ping fails
2. Modify the network card configuration file
# vim /etc/sysconfig/network-scripts/ifcfg-eth0
Add the following configuration:
ONBOOT=yes
BOOTPROTO=static
IPADDR=IP address
NETMASK=255.255.255.0
GATEWAY=Gateway
DNS1=8.8.8.8
:wq Save and exit
3. Restart the network service
#service network restart
4. Test and find that ping fails. . .
5. Okay, there is something wrong with the configuration. Shut down first
# poweroff
6. Configure the network card
Click on Network Adapter
7. Change network connection
Select Hardware-->Network Adapter--> Select Bridge Mode and check the box to copy the physical network connection Status --> OK
8. Start the virtual machine and test the network
Test passed~~~
The above is the detailed content of An example of configuring a static IP address for linux to access the external network. For more information, please follow other related articles on the PHP Chinese website!