首页主机资讯如何用ifconfig查看Ubuntu的网络接口

如何用ifconfig查看Ubuntu的网络接口

时间2025-10-11 00:33:03发布访客分类主机资讯浏览1352
导读:在 Ubuntu 中,ifconfig 命令可以用来查看网络接口的信息。不过需要注意的是,在较新的 Ubuntu 版本中(18.04 及以后),ifconfig 已被弃用,推荐使用 ip 命令。但是,你仍然可以通过安装 net-tools...

在 Ubuntu 中,ifconfig 命令可以用来查看网络接口的信息。不过需要注意的是,在较新的 Ubuntu 版本中(18.04 及以后),ifconfig 已被弃用,推荐使用 ip 命令。但是,你仍然可以通过安装 net-tools 包来使用 ifconfig

以下是如何使用 ifconfig 查看网络接口的步骤:

  1. 打开终端:你可以通过按 Ctrl + Alt + T 快捷键打开终端。

  2. 安装 net-tools(如果尚未安装): 如果你的系统中没有安装 ifconfig,可以通过以下命令安装:

    sudo apt update
    sudo apt install net-tools
    
  3. 使用 ifconfig 查看网络接口: 输入以下命令来查看所有活动的网络接口及其相关信息:

    ifconfig
    

    这将显示类似以下的信息:

    eth0: flags=4163<
        UP,BROADCAST,RUNNING,MULTICAST>
          mtu 1500
            inet 192.168.1.10  netmask 255.255.255.0  broadcast 192.168.1.255
            inet6 fe80::a00:27ff:fe4e:66a1  prefixlen 64  scopeid 0x20<
        link>
        
            ether 08:00:27:4e:66:a1  txqueuelen 1000  (Ethernet)
            RX packets 1003421  bytes 123456789 (117.7 MiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 987654  bytes 987654321 (941.5 MiB)
            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
            inet6 ::1  prefixlen 128  scopeid 0x10<
        host>
        
            loop  txqueuelen 1000  (Local Loopback)
            RX packets 264  bytes 22032 (21.5 KiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 264  bytes 22032 (21.5 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    

    输出中显示了每个网络接口的详细信息,包括 MAC 地址、IP 地址、接收和发送的数据包数量等。

如果你使用的是较新的 Ubuntu 版本并且更喜欢使用 ip 命令,可以使用以下命令来查看网络接口:

ip addr show

或者查看路由表:

ip route show

这些命令提供了与 ifconfig 类似的功能,并且是当前推荐的工具。

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!


若转载请注明出处: 如何用ifconfig查看Ubuntu的网络接口
本文地址: https://pptw.com/jishu/723085.html
Ubuntu ifconfig中broadcast有什么作用 Debian与K8s的集成解决方案

游客 回复需填写必要信息