In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to set up the network in linux in vmware". In the daily operation, I believe that many people have doubts about how to set up the network in linux in vmware. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to set up the network in linux in vmware". Next, please follow the editor to study!
If your XXX card is not supported by the kernel, and you are afraid that the kernel you compiled will cause system damage, you can try this method ^ _ ^
Vmware three Internet connection settings:
1.bridge:
Vmnet0 is used by default
Set the ip settings of the virtual machine to the same network segment of the host without using ip, and the rest are the same as the host:
For example, the host ip is 10.70.54.31 and the virtual machine ip is 10.70.54.22. Virtual machine host virtual machine Internet communication can be realized if the netmask,broadcast,gateway,dns is the same as the host.
2.nat:
Vmnet8 is used by default
Set the virtual machine to use dhcp to access the Internet, select "automatically obtain ip" under windows, and enable dhcp service under linux.
You can also set it manually:
Ip is set to the same network segment as vmnet8. The gateway of vmnet8, usually xxx.xxx.xxx.2, can be found in the gateway (/ etc/vmware/vmnet8/nat/nat.conf) of vmnet8 when gateway is set.
The netmask,broadcast settings are the same as vmnet8 and the dns settings are the same as the host.
For example, vmnet8 ip:172.16.249.1 gw: 172.16.249.2
Virtual machine settings: ip: 172.16.249.100 gw: 172.16.249.2
3.host-only:
Vmnet1 is used by default
Set the ip settings of the virtual machine to the same network segment as vmnet1, set gateway to ip of vmnet1, the rest settings are the same as vmnet1, and the dns settings are the same as the host
For example, vmnet1 ip: 172.16.245.1
Virtual machine settings: ip: 172.16.245.100 gateway: 172.16.245.1
This enables virtual machine host communication, but the virtual machine Internet is still unable to communicate
Virtual machines communicate with the Internet:
1. Enable host routing function
two。 Set iptables to make the host a nat server
1. Echo 1 > / proc/sys/net/ipv4/ip_forward so that the host has the routing function
2. Iptables-t nat-A POSTROUTING-o eth0-s 172.16.245.0 Universe 24-j MASQUERADE
This rule means that the source ip from 172.16.245.0 Universe 24 packet is disguised as eth0 ip to realize the communication between the virtual machine and the Internet.
If the network interface is ppp+ or pppoe, it needs to be modified to-o pppoe
Of course,-s 172.16.245.0Z24 should also be modified according to the actual situation.
There are two ways to surf the Internet in qemu:
User mode network:
It is very simple to realize the virtual machine access to the Internet in this way, similar to adding the-user-net parameter when nat,qemu in vmware starts, and the virtual machine uses dhcp mode to communicate with the Internet, but it is not convenient for the virtual machine to communicate with the host in this way.
Tap/tun network:
This method is a little more complex than user mode, but it is easy for virtual machines, Internet virtual machines, and hosts to communicate when they are set up.
Host-only,qemu, which is similar to vmware in this way, uses tun/tap devices to add a virtual network device (tun0) to the host, which can then be configured like a real network card.
First, tap/tuns devices are supported in the kernel:
Device Drivers->
Networking support->
[M] Universal TUN/TAP device driver support
If the current kernel does not support it, you can recompile and only add the corresponding modules. The method is very simple:
Cp the current kernel configuration file to the kernel source directory:
[root@LFS ~] # cp / boot/config- [kernel-version] / usr/src/linux
[root@LFS ~] # cd / usr/src/linux
Configure the kernel and select the module (M) for TUN/TAP, as shown above:
[root@LFS ~] # make menuconfig
Recompile only the module (M), not what the core (*) supports:
[root@LFS ~] # make modules
After compilation, you can find tun.ko under / usr/src/linux/drivers/net:
[root@LFS net] # ls-l / usr/src/linux/drivers/net/tun.ko
-rw-r--r-- 1 root root 11116 Mar 23 20:29 / usr/src/linux/drivers/net/tun.ko
[root@LFS net] #
Cp it to the appropriate location of the module directory of the current kernel:
[root@LFS net] # cp / usr/src/linux/drivers/net/tun.ko / lib/modules/ `uname-r` / kernel/drivers/net
Re-establish module dependencies:
[root@LFS net] # depmod
You can load it now:
[root@LFS net] # modprobe tun
Check it out:
[root@LFS net] # lsmod | grep tun
Tun 8704 0
[root@LFS net] #
OK. Successfully do not recompile the entire kernel and add special module support
If your xx card is not supported by the kernel and can be compiled into a module, if you are afraid of problems after recompiling the kernel, you can use this method to compile only the module you need, then manually install it to the appropriate location, and then load it.
In this way, the compilation speed is faster than compiling the entire kernel without any damage to the system, so you can use the XX card. ^ _ ^
Pay attention to three points:
1. The kernel source code must be exactly the same as the current kernel version, otherwise the compiled module cannot be used.
two。 Note that only make modules (compile module), no make modules_install (automatically install module to / lib/modules)
3. You must run depmod before loading the newly compiled module, otherwise modprobe will not find it
In fact, using the current kernel configuration file (/ boot/config- [kernel-version]), adding only the modules you need and not making any other changes, make modules_install should not have a problem.
However, the safest way is to install it manually, and the control is more secure in your own hands: -)
OK, switch back to the qemu Internet problem.
If you use udev to manage devices (usually all 2.6.x kernel distributions already use udev), the / dev/net directory will be automatically created after modprobe tun, and the tun device will be created with the relevant links:
[root@LFS net] # ls-l / dev/net/tun
Lrwxrwxrwx 1 root root 6 Mar 25 15:35 / dev/net/tun->.. / tun
[root@LFS net] #
If, unfortunately, you don't see it, you'll have to do the work manually.
At this point, the study on "how to set up the network in linux in vmware" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.