0 Replies Latest reply on Jul 11, 2016 2:23 PM by Pragalathan M

    How to specify outbound interface in wildfly 10?

    Pragalathan M Newbie

      Hi,

      I am trying to run two instances of wildfly 10 in one AWS EC2 machine. I want each instance to use different NICs and private IPs (and hence their associated EIPs). I need this because, these instances will call a 3rd party service outside AWS and these calls should appear such that they are from different IPs.

       

      Im able to successfully bind different ips/NICs (with port offset) and run these instances and access them successfully via browser. However to check the outbound IP address i am hitting http://icanhazip.com from the server as following and emit the IP address to my browser through JSF.

       

      public String getIp() {
              RequestConfig globalConfig = RequestConfig.custom().setCookieSpec(CookieSpecs.BEST_MATCH)
                      .setConnectTimeout(10_000)
                      .setSocketTimeout(15_000)
                      .build();
              CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultRequestConfig(globalConfig).build();
      
              ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient);
              Client client = new ResteasyClientBuilder().httpEngine(engine).build();
              String ip = client.target("http://icanhazip.com/").request().get(String.class);
              return ip;
      }
      

       

      Though im able to access these instances via two EIPs in browser, both of them emit the EIP of the primary NIC's (private) IP instead of two EIPs.

       

      But the following works properly.

       

      curl --interface <primary NIC's private IP> http://icanhazip.com/

      Output: prints the 1st EIP

       

      curl --interface <secondary NIC's private IP> http://icanhazip.com/

      Output: prints the 2nd EIP

       

      So what i infer is, i need a way to tell wildfly to route all the outbound traffic via a specified NIC (hence it is IP).

       

      I also tried this.

       

             <interface name="management">
                  <nic name="eth1"/>
                  <inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
              </interface>
      

       

      Any help is appreciated.