Page 1 of 1
Connecting two Pi's via Ethernet
Posted: Mon Aug 10, 2015 11:09 am
by bluestarfish
Hi,
I have a project where two Pi's are connected via a standard (non-crossover) ethernet cable where one acts as a controller and the other as a logger. I am having trouble getting them to talk the more so by the fact that I don't have a monitor/keyboard (well HDMI monitor) and so am using SSH to configure them which I lose when I try the direct connection.
The set up I have on one is:
iface eth0 inet static
address 192.168.0.30
netmask 255.255.255.0
And on the other:
iface eth0 inet static
address 192.168.0.40
netmask 255.255.255.0
When they are connected to the wired network I can ssh to both of them and they can ping each other, when I connect them together they can't see each other so it has to be a routing issue. I have looked this up and there is conflicting advice as to the need for a gateway and just what other settings I need (IP tables??).
I am hoping someone can give me a quick pointer in the right direction, one of the Pi's has a GPS attached which I think gets in the way of a normal tty session so I seem to be going in circles sorting this out!
Many thanks,
Scott.
Re: Connecting two Pi's via Ethernet
Posted: Mon Aug 10, 2015 11:15 am
by joan
Is 192.168.0.x your PC's network? If so give the Pi's their own network such as 192.168.1.x
Re: Connecting two Pi's via Ethernet
Posted: Mon Aug 10, 2015 11:18 am
by bluestarfish
Hi,
yes my home network is 192.168.0.x - presume that by moving to another network such as 192.168.1.x that it looks for new routing info?? The reason that I am using the same network is that when they don't work I can put them back on the local network (i.e. into the router) without having to edit the interfaces file otherwise I can't reconnect with ssh which means I am locked out.
But will try this and see how I go - thanks
Scott.
Re: Connecting two Pi's via Ethernet
Posted: Mon Aug 10, 2015 11:19 am
by fruitoftheloom
bluestarfish wrote:Hi,
I have a project where two Pi's are connected via a standard (non-crossover) ethernet cable where one acts as a controller and the other as a logger. I am having trouble getting them to talk the more so by the fact that I don't have a monitor/keyboard (well HDMI monitor) and so am using SSH to configure them which I lose when I try the direct connection.
The set up I have on one is:
iface eth0 inet static
address 192.168.0.30
netmask 255.255.255.0
And on the other:
iface eth0 inet static
address 192.168.0.40
netmask 255.255.255.0
When they are connected to the wired network I can ssh to both of them and they can ping each other, when I connect them together they can't see each other so it has to be a routing issue. I have looked this up and there is conflicting advice as to the need for a gateway and just what other settings I need (IP tables??).
I am hoping someone can give me a quick pointer in the right direction, one of the Pi's has a GPS attached which I think gets in the way of a normal tty session so I seem to be going in circles sorting this out!
Many thanks,
Scott.
The RPi have auto-sensing Ethernet Ports so immaterial what cable type used.
Using Direct Cable Connection one must be like a ""Master"" and the other ""Slave""
http://www.softprayog.in/troubleshootin ... -lan-cable
Re: Connecting two Pi's via Ethernet
Posted: Mon Aug 10, 2015 12:39 pm
by drgeoff
fruitoftheloom wrote:Using Direct Cable Connection one must be like a ""Master"" and the other ""Slave""
Nonsense. There is no requirement for master and slave.
Re: Connecting two Pi's via Ethernet
Posted: Mon Aug 10, 2015 1:05 pm
by fruitoftheloom
drgeoff wrote:fruitoftheloom wrote:Using Direct Cable Connection one must be like a ""Master"" and the other ""Slave""
Nonsense. There is no requirement for master and slave.
Jeez I said LIKE, have you nothing better to post

Re: Connecting two Pi's via Ethernet
Posted: Mon Aug 10, 2015 1:34 pm
by rpdom
fruitoftheloom wrote:drgeoff wrote:fruitoftheloom wrote:Using Direct Cable Connection one must be like a ""Master"" and the other ""Slave""
Nonsense. There is no requirement for master and slave.
Jeez I said LIKE, have you nothing better to post

It's not even like...

They are both equal.
Re: Connecting two Pi's via Ethernet
Posted: Mon Aug 10, 2015 1:39 pm
by Joe Schmoe
I can't believe how clueless you guys are - that you can't see what Fruitie means.
(And this is a bit odd - for me to be supporting Fruitie)
Re: Connecting two Pi's via Ethernet
Posted: Mon Aug 10, 2015 2:03 pm
by fruitoftheloom
Joe Schmoe wrote:I can't believe how clueless you guys are - that you can't see what Fruitie means.
(And this is a bit odd - for me to be supporting Fruitie)
Obviously my English Language Education at a UK State School was only the same as JS's, thanks JS

Re: Connecting two Pi's via Ethernet
Posted: Mon Aug 10, 2015 2:30 pm
by GerardWassink
More importantly: did it work now, Scot?
Another question would be: Why can they not be tested whilst being connected to your home network? You could then ssh-login to both of them to check what happens...
HTH,
Gerard
Re: Connecting two Pi's via Ethernet
Posted: Mon Aug 10, 2015 6:09 pm
by DougieLawson
When they are directly connected does one or the other have another active interface?
What does ifconfig -a and ip route show on both systems?
Whenever I want to do a direct point-to-point interface I'd use a completely different subnet (usually from 172.[16-31].xxx.xxx/16 but with a /24 (255.255.255.0) subnet, one machine gets 172.31.4.10, the other gets 172.31.4.20). That's less confusing and less likely to clash with your normal LAN infrastructure.
Re: Connecting two Pi's via Ethernet
Posted: Mon Aug 10, 2015 10:22 pm
by bluestarfish
Hi,
Sorry for being quiet but I am in Australia so sleep was calling. As the two Pi's are connected to each other I don't have a connection to ssh into them (I don't have a wireless dongle) otherwise it would be relatively easy to fault find, the fact is once I set them up I am locked out as I don't have a connection to SSH and when I put them back on the network they are on the wrong connection so I can't talk to them so it is a real pain trying to work out what is going on.
Anyway I am at work where I do have a HDMI monitor so will try and fault find from here. Note that unlike another previous post I am not trying to bridge them to another computer so I think the port forwarding stuff is not what I need but happy to be corrected. Also I don't think from reading I need to do master / save as again I am not bridging to another network nor creating a true network just a one to one connection.
Will let you know how I go.
Scott.
Re: Connecting two Pi's via Ethernet
Posted: Mon Aug 10, 2015 11:05 pm
by drgeoff
Even though the two RPis are on a different logical subnet you can plug them into the same physical router and/or switch that the rest of your network is using. You can then change the IP address of your computer to put it on the same subnet as the two RPis. The PC can then ssh into the RPis for debugging purposes.
When you have the two RPis communicating to your satisfaction you can join them directly with an ethernet cable.
Re: Connecting two Pi's via Ethernet
Posted: Mon Aug 10, 2015 11:49 pm
by bluestarfish
Hi,
Just to let you know that it is working... there was actually nothing wrong with the set up I had but it took some time to find the new route from one to another so Joan was probably right in that using a network it already knew about meant that it took some time (as in 10 minutes) for it to find the new route and if I had used another network then it should have worked from the go.
So for future you just need to set the addresses as being on the same network and the net mask and it should eventually see each other but this could take some time, clearing the network info would of course help as well.
Anyway all solved so thanks!
Scott.