在 ifconfig
命令中,alias(别名)是指为同一个物理网络接口分配多个IP地址的功能。通过别名,你可以让单个网卡(如 eth0
)绑定多个逻辑子接口(如 eth0:0
、eth0:1
等),每个子接口拥有独立的IP地址。
语法示例:
ifconfig eth0:0 192.168.1.100 netmask 255.255.255.0 up
eth0
创建一个别名接口 eth0:0
,并分配指定的IP和子网掩码。作用场景:
与主接口的关系:
eth0:0
)依赖主接口(eth0
),若主接口宕机,所有别名失效。现代替代方案:
ip addr add
(来自 iproute2
工具包):
bash
ip addr add 192.168.1.100/24 dev eth0 label eth0:0
ifconfig
已逐渐被弃用)。/etc/network/interfaces
或 nmcli
)。ifconfig
(需安装 net-tools
包)。如果需要进一步操作示例或排错,可以告诉我你的具体场景!