ifconfig
是一个用于配置和显示 Linux 内核中网络接口的命令行实用程序。以下是一些常见的 ifconfig
参数及其功能:
查看所有网络接口:
ifconfig
或者
ifconfig -a
指定网络接口:
ifconfig eth0
设置IP地址:
ifconfig eth0 192.168.1.100 netmask 255.255.255.0
启用/禁用接口:
ifconfig eth0 up
ifconfig eth0 down
设置广播地址:
ifconfig eth0 broadcast 192.168.1.255
设置MTU(最大传输单元):
ifconfig eth0 mtu 1500
显示详细信息:
ifconfig eth0
显示特定字段:
ifconfig eth0 hw ether 00:11:22:33:44:55
设置别名:
ifconfig eth0:1 192.168.1.101 netmask 255.255.255.0
删除别名:
ifconfig eth0:1 down
显示路由表:
ifconfig -r
显示ARP缓存:
ifconfig -a -arp
ifconfig
在较新的 Debian 版本中可能已被 ip
命令取代,建议使用 ip
命令进行网络配置和管理。ifconfig
时需要 root 权限。以下是一个完整的示例,展示如何使用 ifconfig
配置一个网络接口:
# 启动 eth0 接口
sudo ifconfig eth0 up
# 设置 IP 地址和子网掩码
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
# 设置广播地址
sudo ifconfig eth0 broadcast 192.168.1.255
# 设置 MTU
sudo ifconfig eth0 mtu 1500
# 查看 eth0 接口的详细信息
ifconfig eth0
通过这些参数,你可以灵活地管理和配置 Debian 系统中的网络接口。