1

I have to make a STUN server in OpenSIPs, and it says that I need to bind 2 IP addresses. http://www.opensips.org/About/News0042

A STUN server uses 2 ips and 2 ports to create 4 sockets on which to listen or respond.
STUN requires 2 routable ip addresses

How can I enable two public IP addresses into one Linux server? I've searched all website, and failed to find the answer.

Jake
  • 1,195
  • 6
  • 21
  • 42

1 Answers1

1

Several options.

Option 1.

You likely just need to use ifconfig from the command line to start

You can assign an additional static IP address to your NIC via the command line. Type ifconfig to get the name of your default adapter. It's typically "eth0". Then do add a secondary address to this adapter, the command is something like the following:

sudo ifconfig eth0:1 inet up netmask 255.255.255.0 192.168.1.55

Where 255.255.255.0 is the netmask of my 8-bit subnet and 192.16.1.55 is an existing IP address that no other device on my subnet is already using.

Option 2.

After you get your server up and running with Option 1, you likely need to find a way to get the IP address assigned by "ifconfig" to persist after a reboot. You could likely stick an ifconfig statement into one of your rc.init files. But most Linux skus have a formal way of configuring an interface with another /etc file. But this step varies between different flavors of Linux. On Ubuntu, this is all defined in the /etc/network/interfaces file. Add these three lines to the bottom of your existing file:

iface eth0:1 inet static
address 192.168.1.55
netmask 255.255.255.0

Option 3 (shameless plug)

Switch to Stuntman ( www.stunprotocol.org ) as your STUN server. Its default mode only requires one IP address to be present on the box. Most client usages of the STUN protocol don't require the second IP address unless to do NAT classification and behavior tests.

selbie
  • 100,020
  • 15
  • 103
  • 173
  • Thanks for your advice. I tried bind second IP address and it failed to enable it on Amazon EC2 Server. [root@ip-10-134-131-113 ~]# sudo ifconfig eth0:1 inet up netmask 255.255.255.192 54.238.57.227 SIOCSIFFLAGS: Cannot assign requested address SIOCSIFNETMASK: Cannot assign requested address SIOCGIFADDR: Cannot assign requested address SIOCSIFBROADCAST: Cannot assign requested address – Jake Dec 28 '13 at 05:34
  • I will try to use Stuntman. If it works, I will let you know. Thank you! – Jake Dec 28 '13 at 05:58
  • @Jake - and if it doesn't work, let me know anyway. :) – selbie Dec 28 '13 at 06:23
  • @Jake - Enabling a second IP address on Amazon EC2 requires hosting a VPC instance. http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html#MultipleIP – selbie Dec 28 '13 at 06:26
  • I guess Coturn STUN / TURN server only requires one IP address too? – baptx Jul 21 '19 at 14:56