none
Tunneling CLI instances through multiple public IPs on an Azure VM running Ubuntu RRS feed

  • Question

  • Hello,

    I'm looking to run multiple Python applications on multiple CLI instances (using tmux, a terminal multiplexer) on an Azure VM. I am aware that you can assign multiple public IPs to an Azure VM. How would I go about binding a different IP to each CLI instance so that all traffic within that particular instance uses the assigned public IP?

    Thanks in advance!


    • Edited by Anakratis Wednesday, September 18, 2019 8:01 PM
    Wednesday, September 18, 2019 8:01 PM

Answers

  • Hi,

    I will suggest for ubuntu.

    I have a ubuntu VM with one interface and two ips attached to it. 

    They are 172.18.8.4 and 172.18.8.5.   Both of then have a public ip paired with it.

    You need to bind the private ip to the cli instance.

    Generally the process or application which you are running will have a setting to take the ip to listed on.

    For example, The below command created a file server and it listens on the interface 172.18.8.4

    python3 -m http.server 8000 --bind 172.18.8.4

    For this server the traffic from the public ip paired with 172.18.8.4 only will be forwarded.

    Let me know the CLI instance which you are running. I hope that will have a parameter to bind with an ip for listening.  

    For the benefit of the community, Please click on "mark as answer" and upvote for all the replies which helped you to solve your problem.


    Friday, September 20, 2019 12:33 PM
    Moderator

All replies

  • Hi Anakratis,

    You can bind different ips to different cli instances.

    Each ip configuration will have a private ip and a public ip as shown below.

    Your first cli instance can listen on the first private ip. As per the example its 172.18.8.4.
    Then all the traffic from the public ip ending with 32 will go to that private ip.

    You second cli instance can listed ion the second private ip 172.18.8.5 . The traffic from the corresponding public ip ending with 103 will be forward to that instance.

    This traffic forwarding from that public ip to the private ip is automatically done by the azure platform.

    Let me know if you need more details

    Thursday, September 19, 2019 7:56 AM
    Moderator
  • Hi jakaruna,

    That's great to hear; I assumed something like this was possible. Do you have any documentation or any resources that detail how to set something like this up within the O.S.? I know you can setup different public IPs through Azure's dashboard, but how would you actually use them and bind them to each CLI within Ubuntu (or any other O.S.)?

    I appreciate the help and quick response :)

    Thursday, September 19, 2019 8:24 AM
  • Hi,

    I will suggest for ubuntu.

    I have a ubuntu VM with one interface and two ips attached to it. 

    They are 172.18.8.4 and 172.18.8.5.   Both of then have a public ip paired with it.

    You need to bind the private ip to the cli instance.

    Generally the process or application which you are running will have a setting to take the ip to listed on.

    For example, The below command created a file server and it listens on the interface 172.18.8.4

    python3 -m http.server 8000 --bind 172.18.8.4

    For this server the traffic from the public ip paired with 172.18.8.4 only will be forwarded.

    Let me know the CLI instance which you are running. I hope that will have a parameter to bind with an ip for listening.  

    For the benefit of the community, Please click on "mark as answer" and upvote for all the replies which helped you to solve your problem.


    Friday, September 20, 2019 12:33 PM
    Moderator
  • Hi jakaruna,

    Wow, I didn't expect it to be so straightforward! I thought I'd have to dive into I.P. routing tables. You've been of great help. Again, thank you for everything and I will do as you asked :)


    • Edited by Anakratis Friday, September 20, 2019 5:05 PM
    Friday, September 20, 2019 4:56 PM
  • Hi jakaruna,

    I just got around to trying the sockets bind function and it wasn't exactly what I had hoped for. I'm using a python wrapper for a specific API and trying to stream data from a site using websockets, while also sending requests using standard HTTP. Essentially, I'd like to be able to bind the entire terminal instance, and everything I do within it, to a secondary I.P.

    During my research I found that something like this may be possible with netns, or network namespaces. You can create a network namespace and bind a specific network interface to the namespace. You can then execute functions and commands in that namespace. I'll give this a shot tomorrow!

    Anakratis

    Saturday, September 21, 2019 9:06 AM
  • Sure. Try out and let us know.


    Monday, September 23, 2019 4:30 AM
    Moderator