0

I created five different containers and authorized their keys for easy access between each other. They have internal ip (10.0.3.***). Now what I am trying is to connect these containers from other computers which are in the same network. I installed openssh-server to my machine for ssh access. But can't connect to container.

I search about it through the google but couldn't find any that works and I couldn't understand some of them.

How to 'ssh' my containers from other machines?

EDIT:

When computers ssh each other they use eth0 or eth1. When computer(which containers are in) tries to connect to containers it uses loopback. Now lets assume we have two different computer, comp1 and comp2, which are in the same network a cisco modem that do not have internet connection. I can connect from comp1 to comp2 by;

'ssh username@comp2-ip'

But I cannot connect comp2's linux containers which are in the loopback. I want to connect them as easy as I connect comp2. Is there a way?

4
  • Can you ping the containers ? – Bahaïka Mar 10 '14 at 12:26
  • From local machine I can ping but from other machines I can't. It says 'Destination Net Unreachable'. – rebuked Mar 10 '14 at 13:16
  • Destination Net Unreachable - in that case they are probably not in the same network (10.0.0.0) segment. – grebneke Mar 10 '14 at 13:36
  • Also see: unix.stackexchange.com/questions/50201/… – grebneke Mar 10 '14 at 13:37
3

Two machines in different (private) networks can't see each other unless both have declared routes to each other. For instance, if you have one machine with an address 10.0.3.1 and a net mask of 255.255.255.0, and another machine with an address 10.0.4.1 and the same (class C) mask, they can't see each other.

They need a shared router that both can see; typically a third machine with 2 IPs, let's say 10.0.3.254 and 10.0.4.254, which has some routing capabilities -- under Linux doing echo 1 > /proc/sys/net/ipv4/ip_forward will be enough for basic stuff.

Then you'll have to declare your router as such on each machine with route or ip route, on the 10.0.3.1 machine:

route add -net 10.0.4.0 netmask 255.255.255.0 gw 10.0.3.254

And the other way around on the 10.0.4.1 machine:

route add -net 10.0.3.0 netmask 255.255.255.0 gw 10.0.4.254

As you're using containers, the container host must act as the router between the containers and the outside world. So activate ip forwarding on it, and add proper routes on the containers, and on the machines you want to access the container from.

0

Here are a few points to get you started:

  1. Can you ping one container from the other? Another machine on the same network?

    $ ping ip-address-of-other-container

    $ ping ip-address-of-other-machine-in-same-network

    If not, there is a networking problem

  2. Can you ssh locally?

    $ ssh ip-address-of-same-container

    If not, sshd might not be running, or there is some firewall problem

  3. Try ssh -v ip-address-of-other-container

    -v will give you debugging information which might reveal more about the issue.

3
  • 1-Yes, I can ping containers from other containers. 2-I can ssh locally. 3-I can connect without any problems. There is no problem connecting containers from the computer they are installed or between each other. What i want is to connect them from another computer through the internet. – rebuked Mar 10 '14 at 13:26
  • Are you following a guide? Maybe update your question with info about exactly what steps you followed to setup external networking. Did you see this as an example: linux.org/threads/… – grebneke Mar 10 '14 at 13:31
  • I edited my question to reflect my problem better. – rebuked Mar 10 '14 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.