大网数据广告活动
服务器运维问答

How to correctly setup multiple IP addresses pointing to one instance in EC2?

· 52CE 我爱测

I currently have one ec2 instance which I'd like to have 2 public IPs pointing to. I have 2 EIPs allocated, 2 network interfaces to which the EIPs are attached and which are both attached to the single EC2 instance running ubuntu…

问题原文

原帖链接 · Shelvacu · CC BY-SA 3.0

I currently have one ec2 instance which I'd like to have 2 public IPs pointing to. I have 2 EIPs allocated, 2 network interfaces to which the EIPs are attached and which are both attached to the single EC2 instance running ubuntu 14.04.2 LTS. The seccond EIP and network interface were added recently, and there is indeed an eth1 that pops up, although I currently have to manually run dhclient, but that's not the problem. The problem is that no packets come through. I have triple-checked my security groups, all of them allow port 80 from any IP address. However, adding a byte-counter rule to iptables such as iptables -A INPUT -i eth1 reveals that exactly 0 packets are reaching my machine through the second interface.

I have found & read this but it doesn't help.

What am I missing? Is there some button I forgot to click?

已采纳解答

原帖链接 · Shelvacu · CC BY-SA 4.0

More than a year later, I finally figured it out! Thanks to this article. In summary:

If you haven't already, run dhclient on the new interface:

# dhclient eth1

Then, figure out what your new private IP address is. You can either look in the EC2 console, or run

ip addr

You also need to know the gateway IP. In most cases it's your.ip.0.1, but just to make sure run:

ip route

And you should see something like:

default via 12.34.0.1 dev eth0

12.34.0.1 is the gateway in this case. For demonstration I'm going to assume the private ip is 12.34.56.78. Now run (as root):

ip rule add from 12.34.56.78 table 1000
ip route add default via 12.34.0.1 dev eth1 table 1000
ip route flush cache

To test your configuration:

curl --interface 12.34.56.78 ifconfig.me

Then, to make your changes permanent, add to your /etc/network/interfaces those commands and their oppposites:

auto eth1
iface eth1 inet dhcp
  up ip rule add from 12.34.56.78 table 1000
  up ip route add default via 12.34.0.1 dev eth1 table 1000
  down ip rule del from 12.34.56.78 table 1000
  down ip route del default via 12.34.0.1 dev eth1 table 1000

NOTE: Make sure that you have a snapshot of your instance before you change the persistent network settings, in case something breaks and you are not able to access your instance.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-03-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。