在 Linux 中,ifconfig 本身不能直接“绑定多个 IP”到一张网卡的高级方式(如 ip addr add),但可以通过**给网卡添加别名(alias)**的方式来“绑定”额外 IP。不过需要注意:
ifconfig 已逐步被 ip 命令取代ifconfig
例如网卡是 eth0
ifconfig eth0:0 192.168.1.100 netmask 255.255.255.0 up
说明:
eth0:0 是虚拟网卡别名192.168.1.100 是要绑定的 IPeth0:1、eth0:2 …示例:
ifconfig eth0:1 192.168.1.101 netmask 255.255.255.0 up
ifconfig
或
ip addr
ifconfig eth0:0 down
vi /etc/sysconfig/network-scripts/ifcfg-eth0:0
内容示例:
DEVICE=eth0:0
BOOTPROTO=static
IPADDR=192.168.1.100
NETMASK=255.255.255.0
ONBOOT=yes
重启网络:
service network restart
ip addr add 192.168.1.100/24 dev eth0
查看:
ip addr show eth0
删除:
ip addr del 192.168.1.100/24 dev eth0
如果你告诉我:
我可以给你更精确的配置示例。