帮助中心>阿里云服务器怎么实现绑定多IP地址?

阿里云服务器怎么实现绑定多IP地址?

0 5006
发布于:2021-06-16 21:10:40

经常有客户咨询阿里云服务器怎么实现绑定多IP地址? 阿里云服务器多个弹性公网IP是否可以绑定到一台实例上?本文通过实操的方式为大家介绍,步骤相对较多阿里云控制台步骤有所简化,如果有什么不理解可以联系我们。


配置前须知

1、参考实例规格族绑定弹性网卡和内网IP的个数限制:https://help.aliyun.com/document_detail/25378.html

阿里云服务器支持绑定的IP数(固定Ip和弹性公网IP之和):(弹性网卡-1)*单网卡私有IP+1

以hfc7实例规格“2核4G”为例可绑定的IP数为:(2-1)*6+1=7个;

注意:云服务器封顶绑定IP数21个,因为弹性公网IP一个地域仅支持申请20个。


2、配置弹性网卡:https://help.aliyun.com/document_detail/56955.html 

3、分配辅助私网IP地址:https://help.aliyun.com/document_detail/101180.htm

5、建议您服务器创建快照备份。操作流程请参见创建快照


配置流程

一、阿里云控制台配置

1、购买阿里云ECS服务器

CPU&内存:1核1 GiB

操作系统:CentOS 7.8 64位

实例规格:ecs.s6-c1m1.small

实例规格族:ecs.s6


2、创建弹性网卡绑定阿里云服务器


3、创建两个弹性公网ip绑定到,分别绑定到辅助网卡的主私网IP和辅助私网IP上。

下图已经绑定完成


二、Cenots 7服务器内部配置流程

1、查看网卡信息并没有加载eth0

[root@iZ7u1o01onqjo4Z ~]# ip a

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

    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

    inet6 ::1/128 scope host 

       valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    link/ether 00:16:3e:02:3b:0b brd ff:ff:ff:ff:ff:ff

    inet 172.19.6.126/24 brd 172.19.6.255 scope global dynamic eth0

       valid_lft 315359681sec preferred_lft 315359681sec

    inet6 fe80::216:3eff:fe02:3b0b/64 scope link 

       valid_lft forever preferred_lft forever

3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000

    link/ether 00:16:3e:26:67:2e brd ff:ff:ff:ff:ff:ff


2、参考:https://help.aliyun.com/document_detail/56955.html 配置弹性网卡

[root@iZ7u1o01onqjo4Z ~]# wget https://image-offline.oss-cn-hangzhou.aliyuncs.com/multi-nic-util/multi-nic-util-0.6.tgz

--2021-06-16 20:30:44--  https://image-offline.oss-cn-hangzhou.aliyuncs.com/multi-nic-util/multi-nic-util-0.6.tgz

正在解析主机 image-offline.oss-cn-hangzhou.aliyuncs.com (image-offline.oss-cn-hangzhou.aliyuncs.com)... 118.31.232.173

正在连接 image-offline.oss-cn-hangzhou.aliyuncs.com (image-offline.oss-cn-hangzhou.aliyuncs.com)|118.31.232.173|:443... 已连接。

已发出 HTTP 请求,正在等待回应... 200 OK

长度:9149 (8.9K) [application/x-gzip]

正在保存至: “multi-nic-util-0.6.tgz”

100%[======================================>] 9,149       --.-K/s 用时 0s      

2021-06-16 20:30:44 (52.0 MB/s) - 已保存 “multi-nic-util-0.6.tgz” [9149/9149])


[root@iZ7u1o01onqjo4Z ~]# tar -zxvf multi-nic-util-0.6.tgz

multi-nic-util-0.6/

multi-nic-util-0.6/install.sh

multi-nic-util-0.6/src/

multi-nic-util-0.6/src/dhcp/

multi-nic-util-0.6/src/dhcp/dhclient-exit-hooks

multi-nic-util-0.6/src/dhcp/dhclient-exit-hooks-for-debug

multi-nic-util-0.6/src/dhcp/dhclient-down-hooks

multi-nic-util-0.6/src/udev/

multi-nic-util-0.6/src/udev/rule_generator.functions

multi-nic-util-0.6/src/udev/write_net_rules

multi-nic-util-0.6/src/udev-rules/

multi-nic-util-0.6/src/udev-rules/61-eni.rules

multi-nic-util-0.6/src/udev-rules/75-persistent-net-generator.rules

multi-nic-util-0.6/src/udev-rules/60-net.rules

multi-nic-util-0.6/src/eni-utils/

multi-nic-util-0.6/src/eni-utils/eni-hotplug

multi-nic-util-0.6/src/eni-utils/eni-function

multi-nic-util-0.6/src/eni-utils/net.hotplug

multi-nic-util-0.6/src/eni-utils/eni-cleanup

multi-nic-util-0.6/src/eni-utils/eni-ifscan

multi-nic-util-0.6/src/eni-utils/eni-version

multi-nic-util-0.6/src/eni-utils/eni-helper

multi-nic-util-0.6/src/boot/

multi-nic-util-0.6/src/boot/eni.service

multi-nic-util-0.6/src/boot/systemd-udevd.service

multi-nic-util-0.6/src/boot/eni-service

multi-nic-util-0.6/src/lib/

multi-nic-util-0.6/src/lib/distro.sh

[root@iZ7u1o01onqjo4Z ~]# cd multi-nic-util-0.6

[root@iZ7u1o01onqjo4Z multi-nic-util-0.6]# bash install.sh

the file /lib/udev/write_net_rules NOT exist...

the file /lib/udev/rule_generator.functions NOT exist...

delete the file: /etc/udev/rules.d/70-persistent-net.rules

replace the file: /lib/udev/rules.d/60-net.rules

Created symlink from /etc/systemd/system/multi-user.target.wants/eni.service to /usr/lib/systemd/system/eni.service.

ecs_mq.service                                enabled 


3、重启网卡

[root@iZ7u1o01onqjo4Z multi-nic-util-0.6]# systemctl restart eni.service


4、测试绑定到弹性网卡主ip的弹性公网IP已经可以正常访问,说明配置没问题。

[root@iZ7u1o01onqjo4Z multi-nic-util-0.6]# ip a

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

    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

    inet6 ::1/128 scope host 

       valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    link/ether 00:16:3e:02:3b:0b brd ff:ff:ff:ff:ff:ff

    inet 172.19.6.126/24 brd 172.19.6.255 scope global dynamic eth0

       valid_lft 315359623sec preferred_lft 315359623sec

    inet6 fe80::216:3eff:fe02:3b0b/64 scope link 

       valid_lft forever preferred_lft forever

3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    link/ether 00:16:3e:26:67:2e brd ff:ff:ff:ff:ff:ff

    inet6 fe80::216:3eff:fe26:672e/64 scope link tentative 

       valid_lft forever preferred_lft forever


5、参考分配辅助私网IP地址,配置单网卡多个内网IP

[root@iZ7u1o01onqjo4Z multi-nic-util-0.6]# cat /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1

BOOTPROTO=dhcp

ONBOOT=yes

TYPE=Ethernet

USERCTL=yes

PEERDNS=no

IPV6INIT=no

PERSISTENT_DHCLIENT=yes

HWADDR=00:16:3e:26:67:2e

DEFROUTE=no

[root@iZ7u1o01onqjo4Z multi-nic-util-0.6]# 

[root@iZ7u1o01onqjo4Z multi-nic-util-0.6]# vi /etc/sysconfig/network-scripts/ifcfg-eth1

[root@iZ7u1o01onqjo4Z multi-nic-util-0.6]# 

[root@iZ7u1o01onqjo4Z multi-nic-util-0.6]# cat /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1

BOOTPROTO=no

ONBOOT=yes

TYPE=Ethernet

USERCTL=yes

PEERDNS=no

IPV6INIT=no

PERSISTENT_DHCLIENT=yes

HWADDR=00:16:3e:26:67:2e

IPADDR0=172.19.6.127

IPADDR1=172.19.6.129

DEFROUTE=no

[root@iZ7u1o01onqjo4Z multi-nic-util-0.6]# 

[root@iZ7u1o01onqjo4Z multi-nic-util-0.6]# service network restart

Restarting network (via systemctl):                        [  OK  ]

[root@iZ7u1o01onqjo4Z multi-nic-util-0.6]# 

[root@iZ7u1o01onqjo4Z multi-nic-util-0.6]# 

[root@iZ7u1o01onqjo4Z multi-nic-util-0.6]# ip a

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

    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

    inet6 ::1/128 scope host 

       valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    link/ether 00:16:3e:02:3b:0b brd ff:ff:ff:ff:ff:ff

    inet 172.19.6.126/24 brd 172.19.6.255 scope global dynamic eth0

       valid_lft 315359953sec preferred_lft 315359953sec

    inet6 fe80::216:3eff:fe02:3b0b/64 scope link 

       valid_lft forever preferred_lft forever

3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    link/ether 00:16:3e:26:67:2e brd ff:ff:ff:ff:ff:ff

    inet 172.19.6.127/16 brd 172.19.255.255 scope global eth1

       valid_lft forever preferred_lft forever

    inet 172.19.6.129/16 brd 172.19.255.255 scope global secondary eth1

       valid_lft forever preferred_lft forever

    inet6 fe80::216:3eff:fe26:672e/64 scope link 

       valid_lft forever preferred_lft forever


三、测试结果

分别访问三个公网IP地址,均可以正常访问了,说明配置没问题。


扫码赞赏,鼓励支持

还没有人赞赏,快来当第一个赞赏的人吧!
    强势安利

    阿里云文件存储NAS和对象存储OSS有什么不同?

    2021-06-12 22:49:46

    强势安利

    阿里云镜像和快照有什么区别?有什么关系?

    2021-06-17 10:23:07


    关键词: 阿里云服务器
    提交成功,系统已安排等保测评顾问稍后为您服务
    微信咨询 获取代理价(更低折扣)
    更低报价 更低折扣 代金券申请
    咨询热线:18150038128
    操作成功
    操作失败
    申请优惠
    立即申请优惠
    提交成功,系统已安排等保测评顾问稍后为您服务
    微信咨询 获取代理价(更低折扣)
    更低报价 更低折扣 代金券申请
    咨询热线:18150038128
    操作成功
    操作失败