Article Directory
- First, check the IP address
- Second, the configuration card
- Third, pay attention
- Fourth, the local virtual machine settings Solution can not access a static IP
- 1, the system administrator to open VMWare
- 2. Select the Virtual Network Editor menu
- 3, select this line VMnet8
- 4, restore default settings VMnet8
- 5, modify the parameters of VMnet8
- 6, NAT settings
- 7. Save Settings
- 8. Verify that the virtual NAT mode
- 9, start the virtual machine CentOS7
- 10, do not set a static IP address of CentOS7
- 11, restart CentOS7 network services
- 12, test results
- 13 Notes
- V. Copyright
First, check the IP address
1, ifconfig command
ifconfig is the Linux command to view and configure the network card,
The figure above, we focus on five areas of information:
1) name of the NIC: NIC i.e. the device name, the machine is LO (Loopback full name, a loopback address is often assigned to the address 127.0.0.1, to the native communication, the process directly returns after the kernel, does not in any network appear); eth0 NIC is true, if the server has multiple network cards, network cards will be named eth0, eth1, eth2, ....... Note: The names of actual card is not necessarily begin with eth, it may also be no (built by the motherboard bios of the card), ens (on behalf of the motherboard bios has built-in PCI-E card), enp2s (PCI-E NIC independence), etc., behind the number does not necessarily start from zero.
2) IP Address: inet contents of an IP address, we often say that the IP address is the address of IPV4, IPV6 is the content after inet6, temporarily not concerned.
3) Subnet Mask: The contents netmask is the subnet mask.
4) NIC status:
<UP,BROADCAST,RUNNING,MULTICAST>
UP: NIC is active.
BROADCAST: NIC broadcast address, broadcast packets can occur.
MULTICAST: multicast packets card can occur.
LOWER_UP: L1 is activated, i.e. the network cable is plugged in.
5) MAC Address: MAC address of the manufacturer is given, each card has an address, corresponding to serial number.
2, ip addr command
content and ifconfig ip addr command displays almost, not explained. Note: ip
addr command to display the IP address and subnet mask together, such as: 172.16.0.7/20
.
Second, the configuration card
Each card has a configuration file, stored in / etc / sysconfig / network-scripts directory, file name ifcfg-网卡
, network card eth0 configuration file is ifcfg-eth0
as follows:
1, a dynamic IP address
If the dynamic allocation of IP method, ifcfg-eth0 is as follows:
TYPE=Ethernet # 网卡类型。
PROXY_METHOD=none # 代理模式。
BROWSER_ONLY=no # 只是浏览器。
BOOTPROTO=dhcp # dhcp-动态分配,static-静态分配(重要)。
DEFROUTE=yes # 启动默认路由。
IPV4_FAILURE_FATAL=no # 不启用IPV4错误检测功能。
IPV6INIT=yes # 启用IPV6协议。
IPV6_AUTOCONF=yes # 自动配置IPV6地址。
IPV6_DEFROUTE=yes # 用IPV6默认路由。
IPV6_FAILURE_FATAL=no # 不启用IPV6错误检测功能。
IPV6_ADDR_GEN_MODE=stable-privacy # IPV6地址生成模型。
NAME=eth0 # 网卡物理设备名称(重要)。
UUID=63749b32-6852-4535-96a9-58d24732771d
DEVICE=eth0 # 网卡设备名称, 必须和NAME值相同(重要)。
ONBOOT=yes # 是否开机引导。
The above parameters are the default system, only need to focus NOBOOT parameters on it.
2, static IP address
If a static set IP, ifcfg-eth0 is as follows:
TYPE=Ethernet # 网卡类型。
PROXY_METHOD=none # 代理模式。
BROWSER_ONLY=no # 只是浏览器。
BOOTPROTO=static # dhcp-动态分配,static-静态分配(重要)。
DEFROUTE=yes # 启动默认路由。
IPV4_FAILURE_FATAL=no # 不启用IPV4错误检测功能。
IPV6INIT=yes # 启用IPV6协议。
IPV6_AUTOCONF=yes # 自动配置IPV6地址。
IPV6_DEFROUTE=yes # 用IPV6默认路由。
IPV6_FAILURE_FATAL=no # 不启用IPV6错误检测功能。
IPV6_ADDR_GEN_MODE=stable-privacy # IPV6地址生成模型。
NAME=eth0 # 网卡物理设备名称(重要,不必修改)。
UUID=63749b32-6852-4535-96a9-58d24732771d
DEVICE=eth0 # 网卡设备名称, 必须和NAME值相同(重要,不必修改)。
ONBOOT=yes # 是否开机引导。
DNS1=114.114.114.114 # 第1个DSN服务器的IP地址(重要)。
DNS2=1.2.4.8 # 第2个DSN服务器的IP地址(重要)。
IPADDR=192.168.126.128 # IP地址(重要)。
NETMARSK=255.255.255.0 # 子网掩码(重要)。
GATEWAY=192.168.126.2 # 网关(重要)。
3, restart the network card
Using the root user, execute the following command to restart the network services:
systemctl restart network
Third, pay attention
1) If the network card device name in the default VMWare virtual machine, CentOS7 minimal installation is ens33, the configuration file name is ifcfg-ens33.
2) CentOS7 minimize the installation is not activated by default NIC, the NIC needs to manually modify the profile set ONBOOT=yes
.
3) DNS server parameters in the configuration file may be provided in the card may be provided in the /etc/resolv.conf file, as follows:
#Generated by NetworkManager
nameserver 114.114.114.114
nameserver 1.2.4.8
4) If, after VMWare virtual machine, the CentOS7 modified as a static IP, may be unable to access, processing methods, see the next section.
Fourth, the local virtual machine settings Solution can not access a static IP
Installed in VMWare virtual machine CentOS7 local operating systems, dynamic IP addresses change frequently, after setting a static IP address, the local LAN can visit each other, but CentOS7 system can not access the Internet, follow these steps to resolve this problem.
1, the system administrator to open VMWare
2. Select the Virtual Network Editor menu
3, select this line VMnet8
4, restore default settings VMnet8
5, modify the parameters of VMnet8
VM subnet IP addresses and subnet mask of your own to be, if you are unskilled, will be set according to the contents of the image above is not a problem.
6, NAT settings
7. Save Settings
8. Verify that the virtual NAT mode
9, start the virtual machine CentOS7
10, do not set a static IP address of CentOS7
Modify the virtual machine network card configuration files such as / etc / sysconfig / network-scripts / ifcfg-ens33, note that the file name is not necessarily the ifcfg-ens33, determined according to your situation.
1) modify BOOTPROTO parameters, the protocol was changed to a static IP address mode.
BOOTPROTO=static # dhcp-动态分配,static-静态分配(重要)。
2) modify ONBOOT parameters, the start-up ONBOOT option set to yes.
ONBOOT=yes # 是否开机引导。
3) Set IP DSN server, add the following content.
DNS1=114.114.114.114 # 第1个DSN服务器的IP地址。
DNS2=1.2.4.8 # 第2个DSN服务器的IP地址。
4) Set the IP address, subnet mask and gateway parameters CentOS7, add the following.
IPADDR=192.168.226.128 # IP地址(重要)。
NETMARSK=255.255.255.0 # 子网掩码(重要)。
GATEWAY=192.168.226.2 # 网关(重要)。
11, restart CentOS7 network services
systemctl restart network
12, test results
ping about Baidu.
ok。
13 Notes
If you are not familiar with the network knowledge, or virtual machines are not familiar with, as recommended by this article Yihuhuhuapiao, copy parameters.
V. Copyright
C Language Technology Network original article, reproduced please indicate the source link to the article, the author and original.
Source: C Language Technology Network (www.freecplus.net)
Author: Ethics code Agriculture
If the article typos, or content errors, or other suggestions and comments, please correct me message, thank you very much! ! !