以centos7.2为例
centos7服务器主网卡绑定多ip实践演示:
https://cloud.tencent.com/developer/article/1360461
centos7服务器添加辅助网卡绑定多ip实践演示:
https://cloud.tencent.com/developer/article/1360462
Windows服务器主网卡绑定多ip实践演示:
https://cloud.tencent.com/developer/article/1360445
Windows服务器添加辅助网卡及绑定多ip实践演示:
https://cloud.tencent.com/developer/article/1360457
### 复制eth0的网卡文件 ###
[root@VM_1_62_centos ~]# cp /etc/sysconfig/network-scripts/ifcfg-eth{0,1}
### 修改eth1文件 ###
[root@VM_1_62_centos ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
# Created by cloud-init on instance boot automatically, do not edit.
#
# 此处修改为static
BOOTPROTO=static
#
# 此处改为eth1
DEVICE=eth1
# 注释此行
# HWADDR=52:54:00:8a:7a:64
# 添加如下几行
#
# 配置主ip
IPADDR0=10.2.1.211
NETMASK0=255.255.255.0
# 配置辅助ip1
IPADDR1=10.2.1.212
NETMASK1=255.255.255.0
#
# 配置网关
GATEWAY=10.2.1.1
#
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
PERSISTENT_DHCLIENT=yes
### 关闭 rp_filter 校验 ###
[root@VM_1_62_centos ~]# vim /etc/sysctl.conf
# 找到第16行的rp_filter,如果有,就注释掉
# net.ipv4.conf.default.rp_filter = 1 如果有就注释掉
# 在文件结尾加上如下4行
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.eth0.rp_filter = 0
net.ipv4.conf.eth1.rp_filter = 0
### 使其生效 ###
[root@VM_1_62_centos ~]# sysctl -p
### 重启网卡 ###
[root@VM_1_62_centos ~]# systemctl restart network.service
### 查看配置后的效果 ###
[root@VM_1_62_centos ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:8a:7a:64 brd ff:ff:ff:ff:ff:ff
inet 10.2.1.62/24 brd 10.2.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet 10.2.1.101/24 brd 10.2.1.255 scope global secondary eth0
valid_lft forever preferred_lft forever
inet 10.2.1.102/24 brd 10.2.1.255 scope global secondary eth0
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 20:90:6f:16:2d:be brd ff:ff:ff:ff:ff:ff
inet 10.2.1.211/24 brd 10.2.1.255 scope global eth1
valid_lft forever preferred_lft forever
inet 10.2.1.212/24 brd 10.2.1.255 scope global secondary eth1
valid_lft forever preferred_lft forever
如果有错误之处,请您指正!
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。