Thursday 15 May 2014

linux - Using which network interface each Java program uses? -


If I have 2 public IPs on the Linux system then they are presented as virtual network interface names. What Linux says about this.

There is a network interface in linode, eth0. When you add IP addresses, then you are asked to type the article network eth0: 1, eth0: 2 ... eth0: n.

I need to use 2 different Java applications on the same linode I want to use each one of them different public IPs I have to specify which network of each Java instance The interface is used. would it be possible? I am using Debian Linux.

You can use the constructor to create a special server socket associated with the IP address ( 3 parameters). The address determines the network interface that will be used.

For example:

  string ip = "192.168.1.54"; // config file read from int port = 9090; // Similar InetAddress addr = InetAddress.getByName (IP); ServerSocket ServerSocket = New ServerSet (Port, -1, Adr);   

If you have two separate apps and have two different IP addresses, you always use one app to always use an IP and another app to use another app. Want to To ensure this collaboration, you should store the IP address that is considered to be used by each app in a configuration file or something similar.

No comments:

Post a Comment