Linux 网络配置(CentOS7 && RHEL7)

资讯 2024-06-20 阅读:31 评论:0
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

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:

  1. 编辑 /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.

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明

分享:

扫一扫在手机阅读、分享本文

发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • 0.00003374个比特币等于多少人民币/美金

    0.00003374个比特币等于多少人民币/美金
    0.00003374比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00003374比特币等于2.2826 1222美元/16.5261124728人民币。比特币(BTC)美元(USDT)人民币(CNY)0.00003374克洛克-0/22216.5261124728比特币对人民币的最新汇率为:489807.72 CNY(1比特币=489807.72人民币)(1美元=7.24人民币)(0.00003374USDT=0.0002442776 CNY)。汇率更新于2024...
  • 134 USD toBTC Calculator -

    134                            USD                        toBTC                        Calculator -
    For the week (7 days) Date Day 134 USD to BTC Changes Changes % June...
  • 0.00006694个比特币等于多少人民币/美金

    0.00006694个比特币等于多少人民币/美金
    0.00006694比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00006694比特币等于4.53424784美元/32.5436 16人民币。比特币(BTC)美元(USDT)人民币(CNY)0.000066944.53424784【比特币密码】32.82795436 16比特币对人民币的最新汇率为:490408.64 CNY(1比特币=490408.64人民币)(1美元=7.24人民币)(0.00006694USDT=0.0004846456 CNY)汇率更新时...
  • 12年怎么购买比特币?比特币投资,轻松掌控

    12年怎么购买比特币?比特币投资,轻松掌控
    12年怎么购买比特币?买卖比特币可以通过以下交易所进行购买,分别是:欧易官网平台、ZG交易所、艾戴克斯交易所、C2CX交易软件、BaseFEX交易APP、波网交易平台、安银交易所、BitMart交易软件、紫牛币交所交易APP和澳网(AOMEX)交易平台等等十大平台下载,高效安全的数字货币交易平台。How do you buy bitcoins in 12 years? Bitcoins can be purchased through ten major platforms...
  • 0.00015693个比特币等于多少人民币/美金

    0.00015693个比特币等于多少人民币/美金
    0.000 15693比特币等于多少人民币?根据比特币对人民币的最新汇率,0.000 15693比特币等于10.6 1678529美元/76.86554996人民币。比特币(BTC)【比特币价格翻倍】美元(USDT)人民币(CNY)0.000/克洛克-0/5693【数字货币矿机】10.6 167852976.8655254996比特币对人民币的最新汇率为:489,807.72 CNY(1比特币= 489,807.72人民币)(1美元=7.24人民币)(0.00015693 U...
标签列表