Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set the CentOS network card to bridge mode under VMware

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of how to set the CentOS network card to bridge mode under VMware, the content is detailed and easy to understand, the operation is simple and fast, and it has certain reference value. I believe you will gain something after reading this article on how to set CentOS network card to bridge mode under VMware. Let's take a look.

1. Disable the network manager

# chkconfig networkmanager off # service networkmanager stop

2. Create a virtual network card for bridging

# cd / etc/sysconfig/network-scripts # cp ifcfg-eth0 ifcfg-br0

Note: make a backup before modification, and you can restore it in case there is a problem.

3. Edit ifcfg-br0

# vi ifcfg-br0 device= "br0" type= "bridge" onboot= "yes" bootproto=static ipaddr=192.168.1.17 prefix=24 gateway=192.168.1.1 dns1=202.106.46.151dns2=202.106.0.20 delay=0

Note: it is best to switch to the root account, otherwise you may be prompted: E45: 'readonly' option is set (add! To override)

4. Edit ifcfg-eth0

# vi ifcfg-eth0 device= "eth0" nm_controlled= "yes" onboot=yes type=ethernet bridge= "br0" bootproto=none ipaddr=192.168.1.17 prefix=24 gateway=192.168.1.1 defroute=yes ipv4_failure_fatal=yes ipv6init=no name= "system eth0" uuid=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 dns1=202.106.46.151dns2=202.106.0.20hwaddr=00:1e:67:07:ec:30 ipaddr: ip address on the same network segment as your computer gateway: same as your computer's default gateway

5. Restart the network

# service network restart

6. The following error may be prompted:

Bringing up interface eth0: device eth0 does not seem to be present,delaying initialization. [failed]

Solution:

First, open the / etc/udev/rules.d/70-persistent-net.rules content as shown in the following example:

# vi / etc/udev/rules.d/70-persistent-net.rules # this file was automatically generated by the / lib/udev/write_net_rules # program, run by the persistent-net-generator.rules rules file. # # you can modify it, as long as you keep each rule on a single # line, and change only the value of the name= key. # pci device 0x1022:0x2000 (pcnet32) subsystem== "net", action== "add", drivers== "? *", attr {address} = = "00:0c:29:8f:89:9 7", attr {type} = = "1", kernel== "eth*", name= "eth0" # pci device 0x1022:0x2000 (pcnet32) subsystem== "net", action== "add", drivers== "? *", attr {address} = "00:0c:29:50:bd:1 7", attr {type} = "1", kernel== "eth*", name= "eth1"

Record the mac address of the eth1 network card 00:0c:29:50:bd:17

Next, open / etc/sysconfig/network-scripts/ifcfg-eth0

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

Change device= "eth0" to device= "eth1"

Change hwaddr= "00:0c:29:8f:89:97" to the above mac address hwaddr= "00:0c:29:50:bd:17"

Finally, restart the network

# service network restart

Or

# / etc/init.d/network restart

It's normal.

7. Awkwardness after starting the next day

You can surf the Internet after the configuration is completed on the first day, but there is no restart system test at that time, maybe some configurations are not fully effective!

Sadly, I didn't make a backup before modifying the configuration! Fortunately, there is more than one virtual machine, turn on another virtual machine, and refer to restore configuration.

The other virtual machine is configured as nat dhcp, and the "/ etc/sysconfig/network-scripts/ifcfg-eth0" file

Copy to overwrite the local, edit the local "/ etc/udev/rules.d/70-persistent-net.rules" file

I have "eth0" and "eth0" in my "/ etc/udev/rules.d/70-persistent-net.rules" file

There is only one file in the other virtual machine, so delete "eth1" decisively and save it.

Edit the "/ etc/sysconfig/network-scripts/ifcfg-eth0" file and change the value of "hwaddr" to the same value as "attr {address}" in the "70-persistent-net.rules" file.

Delete the file "ifcfg-br0", command: sudo rm ifcfg-br0

Start the network manager: chkconfig networkmanager on; configuration is restored, reboot, restart the computer

Haha, I can surf the Internet again, but I'm still not reconciled!

8. Configure static ip through graphical interface

First look at the ip address obtained through dhcp:

Open a network connection:

Automatically add a "atuo ethernet" after restoring the configuration. Edit it.

Switch to "ipv4 settings", change the method mode to manual manually, click the "add" button, and add the ip address.

Fill in the address ip address you just saw through "ifconfig". The netmask subnet mask is usually "255.255.255.0".

The gateway gateway is the gateway used in the actual system, usually "192.168.1.1.", and some people like to configure it as "192.168.1.254".

Dns servers dns server, refer to the settings in the implementation system, this is more critical, if the configuration is not correct, you will not be able to access the external network (you cannot use the domain name to access the website)

When the modification is complete, click the "apply" button to apply the new settings.

To determine if it is really available this time, restart the system! Ok, everything's fine.

This is the end of the article on "how to set the CentOS network card to bridge mode under VMware". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to set the CentOS network card to bridge mode under VMware". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report