1

I am running Ubuntu on a Amazon EC2 Server. I have a Public IP Address (52.38.20.76).

I am unable to bind the public ip address to UDP Port:
udp listen 52.38.20.76:3478: Cannot assign requested address

So, I am trying to change ifconfig, to show the Public IP Address instead of the Private IP Address. However, the network changes I have tried have not worked.

Edit /etc/network/interfaces.d/eth0.cfg

# The primary network interface
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 52.38.20.76
netmask 255.255.255.0
gateway 172.31.32.1
dns-nameservers 8.8.8.8 8.8.4.4

The Gateway, I based on the results of a "route -n" command:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.31.32.1     0.0.0.0         UG    0      0        0 eth0
172.31.32.0     0.0.0.0         255.255.240.0   U     0      0        0 eth0

Current ifconfig settings:

eth0      Link encap:Ethernet  HWaddr 06:01:36:ee:0f:0d
          inet addr:172.31.47.199  Bcast:172.31.47.255  Mask:255.255.240.0
          inet6 addr: fe80::401:36ff:feee:f0d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:9001  Metric:1
          RX packets:8169768 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8126026 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:6143591550 (6.1 GB)  TX bytes:6277418496 (6.2 GB)

FYI, the Static IP Address (52.38.20.76) is done using Amazon's Elastic IP address.

Anyone have a suggestion on how to change add the Public IP Address to the interfaces?

Thanks!

Daryl

5

This is not how EC2 works.

All EC2 instances sit behind Amazon's NAT infrastructure. It is not possible to directly assign an EIP or other public IP directly to an EC2 instance.

  • That would seem to imply that there is no way to bind the public ip address. That I can only bind the private ip address. – Daryl Mar 23 '16 at 16:41
  • 2
    That's correct. When you assign an EIP to an instance, Amazon configures a 1:1 NAT between the EIP and the private IP of your instance. Why do you think you need to directly bind the public IP? – EEAA Mar 23 '16 at 16:42
0

Your AWS host is not directly aware of its public IP, EIP or otherwise. AWS takes care of that for you. That means your application cannot differentiate between something connecting to the internal IP and external.

From your application perspective you would bind to 0.0.0.0:3478, AWS translates the external address to your internal address.

  • Thanks for your response Jason, great suggestion. Unfortunately, in my particular case, testing 0.0.0.0:3478 generated errors too. – Daryl Mar 24 '16 at 15:30
  • That is odd -- most of the time you can bind to 0.0.0.0 to indicate 'all' local interfaces, such as 127.0.0.1 and your local IP address. – Jason Martin Mar 24 '16 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.