Experimental environmental environment: Mac,vmware Fusion
One, the commonly used virtual machine network connection mode.
NAT: Recommended way. It allows you to switch the network environment (for example, at work and home) without modifying the configuration of the virtual host, while maintaining the normal Internet function.
Bridging: The equivalent of a virtual machine and a host connected to the same router.
Second, select Nat mode
Third, the specific configuration method. 3.1 Use the Dhclient command to dynamically obtain an IP address, thereby networking
This command is used to dynamically assign IP.
After assigning IP, you can use the Ifconfig command to view your IP:
[[Email protected] ~]# ifconfigens33:flags=4163<UP,BROADCAST,RUNNING,MULTICAST> MTU theinet192.168.38.138Netmask255.255.255.0Broadcast192.168.38.255Inet6 fe80::4d7d:d3b:b8ba:2d2c Prefixlen -ScopeID0x20<link>etherxx: 0c: in: b8:b5:TenTxqueuelen +(Ethernet) RX packets2830bytes248423(242.6KiB) RX Errors0Dropped0Overruns0Frame0TX Packets2985bytes405330(395.8KiB) TX Errors0Dropped0Overruns0Carrier0Collisions0Lo:flags= the<UP,LOOPBACK,RUNNING> MTU65536inet127.0.0.1Netmask255.0.0.0Inet6::1Prefixlen -ScopeID0x10Loop Txqueuelen1(Local Loopback) RX packets -bytes1392(1.3KiB) RX Errors0Dropped0Overruns0Frame0TX Packets -bytes1392(1.3KiB) TX Errors0Dropped0Overruns0Carrier0Collisions0
Several key parameters in the above code illustrate:
inet 192.168.38.138 This is the IP address of the NIC Ens33
Netmask 255.255.255.0 This is a subnet mask
Dhclient This command cannot be used continuously, if used two times, it will appear:
3.2 Configuring Static IP
Since a dhclient command has gone wrong, why configure static IP? Because to make it easier for us to find it. With the IP we can access through other machines, if your IP is an old change, is a very troublesome thing, it is not feasible.
To modify a configuration file command:
Vi/etc/sysconfig/network-scripts/ifcfg-ens33
Configuration file Contents:
Type=Ethernetbootproto=Static #这里是静态Defroute=Yespeerdns=yespeerroutes=Yesipv4_failure_fatal=Noipv6init=yesipv6_autoconf=Yesipv6_defroute=Yesipv6_peerdns=yesipv6_peerroutes=Yesipv6_failure_fatal=Noipv6_addr_gen_mode=stable-Privacyname=Ens33uuid=b961637c-a4c0-4913-a161-81dfb4e21d49device=Ens33onboot=Yes #开机起来IPADDR=192.168.38.138 #ip地址Netmast=255.255.255.0 #子网掩码GATEWAY=192.168.38.2 #网关DNS1=119.29.29.29 #dsn
The network service needs to be restarted after the configuration is complete:
Systemctl Restart Network.service
You can then ping some of the popular sites:
This means that it has been configured.
My machine is a Mac, the virtual machine is VMware Fusion and the gateway is not very easy to find when configuring IP with NAT mode. Finally, find the configuration file for VMware Fusion:
Cd/library/preferences/vmware\ fusion/vmnet8/vim dhcpd.conf
192.168.38.2 is the gateway.
Iv. troubleshooting Frequently Asked Questions
1. Can ping the IP, but Ping does not pass the domain name Description DNS is not correct, to check DNS.
2.route-n Check the gateway, if there is no gateway is also unable to surf the internet.
3. Really not, you can switch to bridge mode to see.
4. If there is no ifconfig command, you can use
Yum Install-y ifconfig
Linux Learning (ii) Linux configuration NIC and common network troubleshooting