FreeBSD, Debian, CentOS一个网卡绑定多个IP

网络安全 2021-07-04 10:23www.168986.cn网络安全知识

1. FreeBSD:

配置/etc/rc.conf

ifconfig_interface="i 192.168.1.5 255.255.255.0"

ifconfig_interface_alias0="i 192.168.1.6 255.255.255.0"

注意interface是网卡设备名.

2. Debian

/etc/work/interfaces

auto eth0
iface eth0 i static
address 192.168.1.145

mask 255.255.255.0

work 192.168.1.0
gateway 192.168.1.1

一个IP

auto eth0:1
iface eth0:1 i static
address 192.168.1.146

mask 255.255.255.0

work 192.168.1.0
gateway 192.168.1.1

3.CentOS:

/etc/sysconfig/work-scripts/ifcfg-eth0

DEVICE=eth0
ONBOOT=yes
HWADDR=00:0C:29:16:39:5F
NETMASK=255.255.255.0
IPADDR=192.168.1.147
GATEWAY=192.168.1.1
TYPE=Ether

绑定一个IP, 创建一个文件, ifcfg-eth0

DEVICE=eth0 // 注意还是eth0, 指示此IP绑定到eth0
ONBOOT=yes
HWADDR=00:0C:29:16:39:5F
NETMASK=255.255.255.0
IPADDR=192.168.1.148
GATEWAY=192.168.1.1
TYPE=Ether

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by