centos

centos系统ifconfig命令详解

小樊
91
2025-02-13 09:38:52
栏目: 智能运维

ifconfig 是一个用于配置和显示 Linux 内核中网络接口的命令行实用程序。在 CentOS 系统中,它同样适用。以下是 ifconfig 命令的详细解释:

基本用法

  1. 显示所有网络接口信息

    ifconfig
    
  2. 显示指定网络接口的信息

    ifconfig eth0
    

    其中 eth0 是你要查看的网络接口名称,可能因系统而异(例如 ens33wlan0 等)。

  3. 启用或禁用网络接口

    • 启用接口:
      sudo ifconfig eth0 up
      
    • 禁用接口:
      sudo ifconfig eth0 down
      
  4. 配置网络接口的 IP 地址

    sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
    
  5. 删除网络接口的 IP 地址

    sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0 del
    

常见参数

示例输出解释

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.100  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 1000000  bytes 123456789 (117.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1000000  bytes 123456789 (117.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

注意事项

希望这些信息对你有所帮助!如果你有更多问题,请随时提问。

0
看了该问题的人还看了