ifconfig 是一个用于配置和显示网络接口信息的命令行工具。在 Ubuntu 中,你可以使用许多参数来控制 ifconfig 的行为。以下是一些常用的 ifconfig 命令行参数:
查看所有网络接口:
ifconfig
查看特定网络接口(例如 eth0):
ifconfig eth0
启用网络接口:
sudo ifconfig eth0 up
禁用网络接口:
sudo ifconfig eth0 down
设置 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
显示详细的网络接口统计信息:
ifconfig eth0
显示所有网络接口的统计信息:
ifconfig -a
显示帮助信息:
ifconfig --help
显示版本信息:
ifconfig --version
ifconfig 在较新的 Ubuntu 版本中已经被 ip 命令取代,建议使用 ip 命令来管理网络接口。ifconfig 配置网络接口时,通常需要超级用户权限(即使用 sudo)。以下是一个完整的示例,展示了如何使用 ifconfig 来配置和查看网络接口:
# 查看所有网络接口
ifconfig -a
# 启用 eth0 接口
sudo ifconfig eth0 up
# 设置 eth0 接口的 IP 地址和子网掩码
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
# 查看 eth0 接口的详细信息
ifconfig eth0
# 禁用 eth0 接口
sudo ifconfig eth0 down
希望这些信息对你有所帮助!如果你有任何其他问题,请随时提问。