4

Let suppose we have two network namespaces that belong to the same subnet. In this context I mean same IP address but different routes it needs to take to get to.

ip netns add myns1 
ip netns add myns2

And Java program is running in Linux global namespace, and from Java, how do I connect using Linux name space?

Socket s = new Socket(ip, port);
// the following allows to pass which name space to select...
Socket nameSpace Socket = new SocketWithNameSpace(ip,port,namespace);

Is there any API to pass Linux namespace or is there any native existing library that achieve this and I can call from Java?

Update:

There is Netlink Protocol Library Suite ( http://www.infradead.org/~tgr/libnl/) which is used within C program to switch namespace. Does anyone know if there is any Java API using this library exist for switching between Linux name space.

Any pointer or help or more info is greatly appreciated !

Tanks,

Bhavesh

Bmis13
  • 550
  • 1
  • 8
  • 27
  • Would it be acceptable to just run the Java programming in the namespace (via `ip netns exec`, say)? Or does the program need to be able to communicate over more than one namespace? – Alan Stokes Sep 11 '15 at 22:21
  • We are in VNF management so Java program runs on Global Name space, and it will have to communicate with different device with same IP address from global name space. – Bmis13 Sep 12 '15 at 00:03
  • We are in VNF management so Java program runs on Global Name space, and it will have to communicate with different device with same IP address from global name space (via any VLAN). I hope there is native C++ library which I can call which would communicate with Linux Kernel for routing to correct namespace etc to route packet. – Bmis13 Sep 12 '15 at 00:10

0 Answers0