Linux系统配置IP
LinuxSystem configurationIP
CentOS 7 服务器网卡默认配置文件在 /etc/sysconfig/network-scripts/下,命名的名称一般为:ifcfg-eth0 ifcfg-eth1, eth0表示第一块网卡,eht1表示第二块网卡,依次类推,如果服务器有四块千兆网卡,在系统显示的名称依次为:eth0、eth1、eth2、eth3。
The default configuration file for the CentOS 7 server card is /etc/sysconfig/network-scripts/, commonly named with the following name: ifcfg-eth0 ifcfg-eth1, Eth0, the first webcard, the second web card, etc., if the server has four gigabytes of webcards, the name displayed in the system is: eth0, eth1, eth2, eth3.
修改服务器网卡IP地址命令为 vim /etc/sysconfig/network-script/ifcfg-eth0 。 vim 命令打开网卡配置文件,默认为DHCP方式,配置如下:(实际应用中配置可能不一样,但是主要的配置有就行)
Modify the IP address of the server network card to vim/ etc/ sysconfig/ network-script/ifcfg-eth0. Vim command opens the network card configuration file by default as DHCP mode, as follows: (The configuration may be different in the actual application, but the main configuration is fine)
DEVICE=eth0
BOOTPROTO=DHCP
HWADDR=00:0e:21:14:c7:1e
NOBOOT=yes
TYPE=Ethernet
vim 命令打开网卡配置文件,修改BOOTPROTO为静态分配,同时添加IPADDR、NETMASK、GATEWAY信息如下:
vim command to open the network card configuration file, modify BOOTPROTO to static distribution, and add IPADDR, NETMASK, GATEWAY information as follows:
DEVICE=eth0 #物理设备名
DEVICE=eth0 #Physics Device Name
BOOTPROTO=static #[yes|no](重启网卡是否激活网卡设备)
BOOTOTROTO=static #[yesno] (whether the reboot card activates the netcard device)
HWADDR=00:0e:21:14:c7:1e
NOBOOT=yes # static 静态分配 dhcp DHCP协议
NOBOOT=yes #static static distribution dhcp DHCP
TYPE=Ethernet #网卡类型
TYPE = Ethernet #net card type
IPADDR=192.168.3.7 # IP地址
IPADR = 192.168.3.7 #IP Address
NETMASK=255.255.255.0 #子网掩码
NETMASK = 255.255.255.0 #net mask
GATEWAY=192.168.3.1 #网关地址
GATEWAY = 192.168.3.1 # Gateway Address
服务器网卡配置完毕后,重启网卡服务: /etc/init.d/network restart
Reboot network card service after server card configuration: /etc/init.d/network restart
然后查看 ip 地址,命令为 ifconfig 或 ip address show 查看当前服务器所有网卡的 IP地址。
Then look at the ip address. The IP address of all Internet cards on the current server is ordered ifconfig or ip address show.
CentOS 7 Linux中,如果没有 ifconfig 命令,可以用 ip address show 查看,也可以安装 ifconfig 命令。需安装软件包 net-tools。 安装命令 yum install net-tools -y
In CentOS 7 Linux, if you do not have an ifconfig command, you can view it with ip address show or install an ifconfig command. The package net-tools needs to be installed. Install the command yum install net-tools-y
Linux系统配置DNS
Linux System ConfigurationDNS
网卡IP地址配置完毕,如果服务器需上外网,还需配置域名解析服务(Domain Name System,DNS), DNS主要用于将请求的域名转换为IP地址,DNS地址配置方法如下: 修改 vim /etc/resolv.conf 文件,在文件中加入如下两条:
The IP address configuration of the netcard is complete and, if the server needs to go to the extranet, the domain name parsing service (Domain Name System, DNS), DNS is mainly used to convert the requested domain name to an IP address, DNS address configuration is as follows: Modify the vim/etc/resolv.conf file by adding the following two entries to the document:
nameserver 223.5.5.5 ?# 阿里DNS
Nameserver 223.5.5.5? #AliDNS
nameserver 8.8.8.8 ?#谷歌DNS
#GoogleDNS
如上分别表示主DNS和备DNS,DNS配置完成后,无需重启网络服务,DNS是立即生效。可以 ping -c 6 www.baidu.com 查看返回结果,如果有 IP 返回,则表示服务器DNS配置正确。
The DNS is effective immediately when the main DNS and the DNS configuration are completed. The returns can be viewed at ping-c 6 www.baidu.com, and if IP returns, the server DNS is correctly configured.
Linux网卡名称命名
Linux net card name
CentOS 7 服务器,默认网卡名为 ifcfg-eno1677736,如果想改成 ifcfg-eth0,则使用如下方法进行修改:
CentOS 7 server, default web card named ifcfg-eno167736, modified if you want to change to ifcfg-eth0, using the following method:
编辑 /etc/sysconfig/grub 文件,命名为 vim /etc/sysconfig/grub, 在倒数第二行 quiet 后加入如下代码,
net.ifnames=0 biosdevname=0 如下图Edit /etc/sysconfig/grub files, named vim/etc/sysconfig/grub, and add the following code after the penultimate line Queet:
net.ifnames=0 biosdevname=0
? 2. 执行命令 grub2-mkconfig -o /boot/grub2/grub.cfg 生成新的 grub.cfg 文件,如下图
? 3.? 重命名网卡名称,执行命令 mv ifconfig-eno16777736 ifcfg-eth0,修改 ifcfg-eth0 文件中 DEVICE=eno16777736 为 DEVICE=eth0
♪ 3. ♪ Rename the name of the net card and execute the command mv ifconfig-eno 1677736 ifcfg-eth0, modify the DEVICE=eno1677736 for DEVICE=eth0
? 4. 重启服务器,并验证网卡名称是否为 eth0, Reboot 完后,运行 ifconfig 查看。
4. Reboot the server and verify if the card name is eth0, Reboot after it is finished, run ifconfig view.
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
发表评论