centos查看网卡状态命令(centos7查看网卡状态命令)

centos7 网络管理命令

一.IP

nmcli -p dev 查看网卡,ip,连接状况

或者ip a

ip a s eth0 查看eth0的ip

ip r 查看路由

配置ip的两种方式:

方式一:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

方式二:

nmtui edit eth0

配置好需systemctl restart network重启网络

二.DNS

cat /etc/resolv.conf

可以查看dns情况,但不要直接配置

CENTOS怎样检测网卡状态

由于ifconfig命令没法看到网卡的一些状态, 以下有5种方法查看网卡状态,是否连通网线

How to check physical Network Link Status on Linux (RHEL/Centos)

原文:

There are several ways to check Link status on RHEL,

As far i used to check by 5- ways. Refer Below

1)

# dmesg | grep eth

.....

e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None

e1000: eth1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None

2)

# mii-tool

eth0: negotiated 100baseTx-FD, link ok

eth1: negotiated 100baseTx-FD, link ok

3)

# ethtool eth0 | grep Link

Link detected: yes

4)

# cat /sys/class/net/eth0/operstate

up

5)

# ip link show

2: eth0: mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:0c:29:b0:ef:e4 brd ff:ff:ff:ff:ff:ff

3: eth1: mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:0c:29:b0:ef:ee brd ff:ff:ff:ff:ff:ff

centos怎么查看网卡驱动

查看网卡驱动版本号:ethtool -i 网卡名 如ethtool -i eth0

示例:

[root@nt3 ~]# ethtool eth5

Settings for p6p1:

Supported ports: [ FIBRE ]

Supported link modes: 10000baseT/Full

Supported pause frame use: No

Supports auto-negotiation: No

Advertised link modes: 10000baseT/Full

Advertised pause frame use: No

Advertised auto-negotiation: No

Speed: 10000Mb/s

Duplex: Full

Port: FIBRE

PHYAD: 0

Transceiver: external

Auto-negotiation: off

Supports Wake-on: d

Wake-on: d

Current message level: 0x00000007 (7)

drv probe link

Link detected: yes

[root@nt3 ~]# ethtool -i eth5

driver: ixgbe

version: 3.21.2

firmware-version: 0x1bab0001

bus-info: 0000:05:00.0

supports-statistics: yes

supports-test: yes

supports-eeprom-access: yes

supports-register-dump: yes

supports-priv-flags: no

关于网卡的几个操作的命令:

1.lsmod 查看网卡的模块是否加载,看看是否网卡驱动好了的意思

2. dmesg:查看是否检测到了网卡。

3.ifup ifdown 激活/停止网卡

4.ifconfig 查看网卡是否正常工作。 看看是否网卡有ip,有lo主机回还网络,表示设备没有问题。

windows下 查看的是 ipconfig /all 命令,centos下的 是 ifcofnig 命令

ifconfig 接口

ifconfig eth0(接口) up/down 激活网卡设备,网卡无效。

ifconfig eth0 netmask 255.255.254.0 设置掩码

ifconfig eth0 192.168.0.21 设置eth0的ip地址为0.21

也可以写一行:ifconfig eth0 192.168.0.21 netmask 255.255.255.0

修改后需要重新启动网络设置:service network restart

5.看看网络是否相通

ping -c 10(回显几次) ip/域名

eg: ping -c 192.168.1.1 同 windows的一样。

6.如果上不了网,看下dns填写是否正确: /etc/resolv.conf文件。

7.上不去网的话:看看 默认路由设置错误,也会导致不能上网。

就设计到了route命令:

route 看下 default 的 网关 gateway 是不是你的路由器的ip地址,不是的话就上不了网,需要修改,如何修改呢? 先删除默认路由,这一条。然后再添加默认路由这一条。就可以了。

route del default

route add default gw 192.168.0.254(你的路由器的ip),需要root用户的身份才能操作。

centos查看实时网络带宽占用情况方法

Linux中查看网卡流量工具有iptraf、iftop以及nethogs等,iftop可以用来监控网卡的实时流量(可以指定网段)、反向解析IP、显示端口信息等。

1、安装iftop

centos安装iftop的命令如下:

yum install iftop -y

2、查看网卡实时流量命令:

iftop -i eth1

执行命令查看外网占用带宽情况,能查看到相应IP占用带宽的情况, 从而判断哪个占用带宽最多,是否恶意连接:

如上图,将占用带宽最多的IP,用防火墙或者安全组屏蔽访问即可。当然,最好是观察一段时间,如果是持续占用带宽,加上IP是外地的,那就完全可以屏蔽它。为了更好的监控某个特定IP的带宽访问情况,可以执行命令:

iftop -i eth1 -B -F 182.92.***.20

显示182.92.***.20这个IP与服务器的网卡eth1交互的数据量,单位是Byte。

界面说明:

\"=\"与\"=\",表示的是流量的方向

\"TX\":从网卡发出的流量

\"RX\":网卡接收流量

\"TOTAL\":网卡发送接收总流量

\"cum\":iftop开始运行到当前时间点的总流量

\"peak\":网卡流量峰值

\"rates\":分别表示最近2s、10s、40s 的平均流量

可以通过键盘的\"q\"键退出iftop

未经允许不得转载:便宜VPS网 » centos查看网卡状态命令(centos7查看网卡状态命令)