查看网卡对应网口是否已使用

应用场景

在安装完操作系统进行网卡配置IP地址时,往往不知道操作系统哪几个网卡口插了网线,在不去查看具体设备情况下,可通过本文确认哪个网卡口上插了网线。

如下图所示,存在4个网卡,在配置IP地址时,需要事先确认要去配置哪个网卡。

查看过程

查看所有网卡信息

shell

root@host181:~# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 0c:c4:7a:47:44:a4  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:16 Memory:df600000-df620000 

eth1      Link encap:Ethernet  HWaddr 00:e0:ed:43:8c:4e  
          inet addr:10.16.17.181  Bcast:10.16.17.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:464590 errors:651 dropped:689 overruns:0 frame:651
          TX packets:68621 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:44648440 (44.6 MB)  TX bytes:47221831 (47.2 MB)

eth2      Link encap:Ethernet  HWaddr 0c:c4:7a:47:44:a5  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:17 Memory:df500000-df520000 

eth3      Link encap:Ethernet  HWaddr 00:e0:ed:43:8c:4f  
          inet addr:10.10.10.181  Bcast:10.10.10.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:63671255 errors:651 dropped:4061 overruns:0 frame:651
          TX packets:79242899 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:49119827886 (49.1 GB)  TX bytes:47106704400 (47.1 GB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:30775317 errors:0 dropped:0 overruns:0 frame:0
          TX packets:30775317 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:17379972836 (17.3 GB)  TX bytes:17379972836 (17.3 GB)

shell

root@host181:~# ethtool eth0 | grep 'Link detected'
	Link detected: no
root@host181:~# ethtool eth1 | grep 'Link detected'
	Link detected: yes
root@host181:~# ethtool eth2 | grep 'Link detected'
	Link detected: no
root@host181:~# ethtool eth3 | grep 'Link detected'
	Link detected: yes
root@host181:~#

如上所示,Link detected值为yes的,表示该网卡有连接线,被启用,据此可以去进行eth0和eth3网卡的IP配置。


来源: Transcendent
文章作者: Gavin Wang
文章链接: 查看网卡对应网口是否已使用 | Transcendent
本文章著作权归作者所有,任何形式的转载都请注明出处。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值