Linux 系统查看网卡配置信息
Linux 系统查看网卡配置,有几种方式,分述如下。
- 方法一:ifconfig 命令查看设置网卡
-
ifconfig:查看所有活动网卡信息,能查看 IP 地址和子网掩码,但是不能查看网关和 DNS 地址,还可以临时设置某一网卡的 IP 地址和子网掩码。
[root@cloudgw ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.19.243.202 netmask 255.255.240.0 broadcast 172.19.255.255
ether 00:16:3e:04:2c:c4 txqueuelen 1000 (Ethernet)
RX packets 387660324 bytes 226790748853 (211.2 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 328446865 bytes 259013344959 (241.2 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1 (Local Loopback)
RX packets 249981451 bytes 195165066686 (181.7 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 249981451 bytes 195165066686 (181.7 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0 是第一块网卡,lo 表示本地回环网卡的信息。
-
ifconfig -a:查看所有网卡信息,结果如上所示。 ifconfig eth0:查看具体网卡 eth0 的信息
[root@cloudgw ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.19.243.202 netmask 255.255.240.0 broadcast 172.19.255.255
ether 00:16:3e:04:2c:c4 txqueuelen 1000 (Ethernet)
RX packets 387661202 bytes 226790872151 (211.2 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 328447665 bytes 259013675834 (241.2 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- 方法二:通过 Linux 网络配置文件查看网卡信息 进入 /etc/sysconfig/network-scripts/ 路径,可以看到不同网卡的文件信息。
[root@cloudgw ~]# cd /etc/sysconfig/network-scripts/ [root@cloudgw network-scripts]# ll total 224 -rw-r--r-- 1 root root 38 May 2 2018 ifcfg-eth0 -rw-r--r--. 1 root root 254 May 3 2017 ifcfg-lo ---
查看第一张网卡的信息
[root@cloudgw network-scripts]# cat ifcfg-eth0 DEVICE=eth0 BOOTPROTO=dhcp ONBOOT=yes
更多信息说明,见如下表格。
说明:
-
自动获取 IP 的条件是:必须在局域网内存在 DHCP 服务器。 相同 UUID 网络配置的计算机会导致互相不能上网。
