Linux下查看网络状态的方法

Stella981
• 阅读 691

  当我的设备在机房,懒得去查看网线连接情况;或者设备在远端,没有条件让眼睛亲临现场,我需要在终端查看设备网络接口的物理连接状态。基于此种场景,我就了解了几种关于命令查看网络状态的方法。

  1. ifconfig

  ifconfig是Linux系统自带命令,可以查看接口配置IP的情况、临时配置接口IP(永久配置可以使用yast或者修改/etc/sysconfig/nework/ifcfg-eth0)、查看网卡口的链路状态。

  MYSUSE:/ # ifconfig eth0
  eth0 Link encap:Ethernet HWaddr E0:36:76:D1:9F:B0
  inet addr:192.168.0.1  Bcast:192.168.0.255  Mask:255.255.255.0
  inet6 addr: fe80::e236:76ff:fed1:9fb0/64 Scope:Link
  UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  RX packets:2200774 errors:0 dropped:4647 overruns:0 frame:0
  TX packets:1139522 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:1000
  RX bytes:2684945760 (2560.5 Mb) TX bytes:116659921 (111.2 Mb)
  Interrupt:40

  2. yast/yast2

  yast2是yast的图形化进阶版,像是windows系统里的控制面板功能。命令就是:yast调出yast界面-->选择Network Devices-->Network Settings,打开网络配置界面。

  网卡口有连接网线和已经配置IP的状态:

  Broadcom Ethernet controller
  MAC : e0:36:76:d1:9f:b0
  BusID : 0000:08:00.0

  Device Name: eth0
  Started automatically at boot
  IP address: 192.168.0.1/24

  网卡口未连接网线和未配置IP的状态:

  82599EB 10 Gigabit Dual Port Backplane Connection (Not connected)
  MAC : bc:62:0e:4f:b1:3b
  BusID : 0000:02:00.1
  Device Name: eth5

  The device is not configured. Press Edit to configure.

  3. service network status

  Linux中常用的服务查询方法,查询结果如下所示:

  MYSUSE:/ # service network status
  Checking optional network interfaces:
  eth0 device: Broadcom Corporation NetXtreme BCM5719 Gigabi
  eth0 IP address: 192.168.0.1/24
  eth0 is up                           running
  eth1 device: Broadcom Corporation NetXtreme BCM5719 Gigabi
  No configuration found for eth1                  unused
  eth2 device: Broadcom Corporation NetXtreme BCM5719 Gigabi
  No configuration found for eth2                   unused
  eth3 device: Broadcom Corporation NetXtreme BCM5719 Gigabi
  No configuration found for eth3                   unused
  eth4 device: Intel Corporation 82599EB 10 Gigabit Dual Por
  eth4 DHCP4 client (dhcpcd) is running
  eth4 . . . but is still waiting for data
  eth4 is up                           waiting
  eth5 device: Intel Corporation 82599EB 10 Gigabit Dual Por
  No configuration found for eth5                   unused
  Checking mandatory network interfaces:
  lo
  lo IP address: 127.0.0.1/8
  secondary lo IP address: 127.0.0.2/8
  lo is up                            running
  Checking service network . . . . . . . . . . . running

  4. ip link show eth0

  ip link工具查询可以指定接口进行增删改查。

  MYSUSE:/ # ip link show eth0
  2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
  link/ether e0:36:76:d1:9f:b0 brd ff:ff:ff:ff:ff:ff

  5. ethtool eth0

  ethtool比ip link工具功能更丰富一些。

  MYSUSE:/ # ethtool eth0
  Settings for eth0:
  Supported ports: [ FIBRE ]
  Supported link modes: 1000baseT/Half 1000baseT/Full
  Supports auto-negotiation: Yes
  Advertised link modes: 1000baseT/Half 1000baseT/Full
  Advertised pause frame use: Symmetric
  Advertised auto-negotiation: Yes
  Speed: 1000Mb/s
  Duplex: Full
  Port: FIBRE
  PHYAD: 8
  Transceiver: internal
  Auto-negotiation: on
  Supports Wake-on: d
  Wake-on: d
  Current message level: 0x000000ff (255)
  drv probe link timer ifdown ifup rx_err tx_err
  Link detected: yes

点赞
收藏
评论区
推荐文章
Stella981 Stella981
2年前
Android app ADB命令
\查看设备adbdevicesps这个命令是查看当前连接的设备,连接到计算机的android设备或者模拟器将会列出显示若有多台安卓设备,可以通过在adb后面加上s<设备id对指定设备进行装包、卸载等操作\启动adbadbstartserver\关闭adbadbkillserver\安装软件
Stella981 Stella981
2年前
Linux网络 查看网络配置、测试网络连接、设置网络地址参数
目录查看网络配置1、ifconfig(查看网络接口信息)2、hostname(查看主机名称)3、netstat(查看网络连接情况)4、ss(获取socket统计信息)5、route(查看路由表)测试网络连接1、ping
Stella981 Stella981
2年前
Linux之lldptool命令
1\.描述当我们想在操作系统里面查看网口和交换机连接的状态信息,我们可以使用lldptool这个工具。2.LLDP协议LLDP是一个数据链路层发现协议,LLDP协议使得接入网络的一台设备可以将其主要的能力,管理地址,设备标识,接口标识等信息发送给接入同一个局域网络的其它设备。lldptool工具采用的是LLDP协
Stella981 Stella981
2年前
SpringBoot之actuator
在springBoot中集成actuator可以很方便的管理和监控应用的状态。暴露的Restful接口有:HTTP方法路径描述鉴权GET/autoconfig查看自动配置的使用情况trueGET/configprops查看配置属性,包括默认配置trueGET/beans查看bean及其关系列表
可莉 可莉
2年前
10.11 Linux网络相关 10.12 firewalld和netfilter 10.13 netfilter5表5链介绍 10.14 iptables语法
10.11Linux网络相关ifconfig命令查看网卡IP如果系统没有该命令可以使用yum安装:root@cham2~yuminstallynettools查看网卡IP还可以使用命令:ipaddr,这个显示有点乱!ifconfiga显示所有
Stella981 Stella981
2年前
Android检查设备是否可以访问互联网,判断Internet连接,测试网络请求,解析域名
安卓SDK提供了ConnectivityManager类,那么我们就可以轻松的获取设备的网络状态以及联网方式等信息。 但是要想知道安卓设备连接的网络能不能访问到Internet,就要费一番周折了。 本文为大家介绍三种方式来检查Internet连接状态。1、使用Linux系统pingip的命令方式检查设备的Internet连接状态。 2
Easter79 Easter79
2年前
SpringBoot之actuator
在springBoot中集成actuator可以很方便的管理和监控应用的状态。暴露的Restful接口有:HTTP方法路径描述鉴权GET/autoconfig查看自动配置的使用情况trueGET/configprops查看配置属性,包括默认配置trueGET/beans查看bean及其关系列表
芝士年糕 芝士年糕
1年前
Linux网络配置
在使用3A服务器期间,我们会经常使用到网络配置,下面介绍Linux网络的配置,需要服务器的可以私信我一.网络地址配置1.1网络地址查看–ifconfig命令格式:ifconfig或ifconfig网卡名主要参数信息:1.2网络配置修改临时修改IP地址ifconfig网卡更改后的IP地址language二.路由表配置2.1路由表查看–ro
胖大海 胖大海
1年前
Linux centos7 临时和永久修改IP
临时修改IPifconfigeth0192.168.13.14注意机器重启会失效!永久修改IP第一步查看需修改ip的网卡名称ifconfig第二步修改该网卡配置cd/etc/sysconfig/networkscripts第三步重启网络服务systemctlrestartnetwork这样IP地址就永久修改完成了,我这边使用的3A网
Linux查看网络流量
作为一个非职业运维,不时需要查看Linux服务器上的网络流量状况。本文介绍几个常用的Linux查看网络流量命令,并简要介绍其用法。部分命令系统已经内置,某些命令则需要从软件仓库或者自行编译安装,本文以CentOS系统为例介绍软件安装方法。查看总流量ipip命令来自iproute2util包,是查看、配置网络/路由的工具。作为ifconfig的替代品