General use VMware to open Linux virtual machine Common network type has bridge (bridging mode), Nat,host-only (host only) 3 kinds. NAT: Automatic allocation of IP addresses, only the host (that is, the virtual machine on the computer) can access the virtual machine, through the host access to the network, the advantage is not with other physical host IP conflict, easy to learn and test. Bridge (Bridging mode): Set fixed IP, and the same LAN host can access the virtual machine, like a real host, with the host in the same LAN, the advantage is that the virtual machine can be a real host, the disadvantage is that it may be with other physical host IP conflict. Host-only (host only): Only the host can access the virtual machine and cannot access the network.
In general, we use NAT as a development test and learning, but sometimes we need to deploy the project on our own computer and let other people on the same LAN access it, then we need to use bridge bridging mode.
First, modify the network adapter connection mode of the VMware corresponding virtual machine, select the bridging mode
Open cmd, use ipconfig to view IP configuration of your own computer
In order to avoid IP conflicts, set the IP before you must test yourself to use the IP has been used, you can ping the IP address for testing.
In a Linux system, vi/etc/network/interfaces view IP configuration
which
Auto eth0 #开机自动连接网络
iface lo inet loopback
iface eth0 static #static表示使用固定ip, DHCP presentation using dynamic IP address
192.168.0.115 #设置未被使用的ip地址
netmask 255.255.255.0 #设置子网掩码, the gateway 192.168.0.1 #设置网关 can be viewed through ipconfig
, Through ipconfig you can view
The modified interfaces file is
If you need to set up DNS, use the vi/etc/resolv.conf configuration
Where nameserver is the DNS server IP address, you can configure the first and alternate two DNS servers, as follows
NameServer 192.168.184.1 #设置首选dns
nameserver 192.168.184.2 #设置备用dns
in practical use, it is recommended to remove the annotations to avoid triggering unknown exceptions.
The above configuration is good, service networking Restart Restart network can realize fixed IP address.