lipka
Posts: 8
Joined: Fri Jan 18, 2013 1:00 pm

Connecting RPi to laptop via eth0

Fri Jan 18, 2013 1:11 pm

Hi guys
im trying to connect my Raspberry Pi to laptop via eth0.
On my laptop i have Win7 but i have too PC with ArchLinux.
Laptop is connected to internet via wifi, pc too(usb dongle).

I try connect network cable to RPi and laptop, then turn on RPi and after 2 min
i have scan lan using Advanced port scanner, it shows nothing.

On my pc i tryied connect network cable to pc and scan using nmap.

How should i configure RPi for connection this way?
I need this to use ssh, and testing GPIO circuits.
Any help?

photomankc
Posts: 80
Joined: Fri Aug 24, 2012 12:58 pm

Re: Connecting RPi to laptop via eth0

Fri Jan 18, 2013 7:56 pm

Are you setting up a static IP on the Pi and the laptop? If not then you are not going to get them connected.

What is the output of

Code: Select all

ifconfig -a
on the pi?

What is the output of

Code: Select all

ipconfig 
on the laptop?

User avatar
dasmau89
Posts: 13
Joined: Wed Jan 02, 2013 3:19 pm

Re: Connecting RPi to laptop via eth0

Sat Jan 19, 2013 2:04 pm

the most easy way is to use dhcp, so you could:
- connect the pi to a router (most routers do dhcp in the default config)
- connect the pi to 1 of your ArchLinux PC's and run a dhcp-server (https://wiki.archlinux.org/index.php/Dhcpd) on the PC and use connect with the laptop
- find a windows-based dhcp server

I asume you have this setup:
internet -> router -> wlan -> windows-laptop -> ethernet -> pi
(and plugging the pi in the router is no option)
- you could bridge (on the laptop) the ethernet and the wlan interface, wich should 'expand' the wlan over ethernet and give your pi an ip
thou shalt not kill -9

lipka
Posts: 8
Joined: Fri Jan 18, 2013 1:00 pm

Re: Connecting RPi to laptop via eth0

Sat Jan 19, 2013 7:55 pm

I have tried to connect RPi to my virgin media router but it is 2floors down, it's why I want to connect RPi directly to PC or laptop, my tv is 2 floors down too . I thought RPi have dhcp on at boot, so it should be easy to find it on my arch pc, but nmap doesn't find it :-\

drirr
Posts: 54
Joined: Sun Sep 09, 2012 8:06 am

Re: Connecting RPi to laptop via eth0

Sun Jan 20, 2013 4:09 pm

lipka wrote:I have tried to connect RPi to my virgin media router but it is 2floors down, it's why I want to connect RPi directly to PC or laptop, my tv is 2 floors down too . I thought RPi have dhcp on at boot, so it should be easy to find it on my arch pc, but nmap doesn't find it :-\
Well, does your laptop act as a DHCP-server? Even if your router acts as a DHCP-server the rpi isn't connected to it and wont be able to ask it for a lease.
Raspberry Pi (rev 000f, 512MB RAM) with heatsinks and a modmypi case running Arch Linux ARM (armv6h) hooked up to a 750GB 2.5" USB-harddrive

pepedog
Posts: 1043
Joined: Fri Oct 07, 2011 9:55 am

Re: Connecting RPi to laptop via eth0

Sun Jan 20, 2013 7:54 pm

Lipka,
You will need to make rpi and laptop Ethernet static ip addresses.
Or make laptop a wireless bridge, if router allocates addresses. Then pi can access Internet.

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: Connecting RPi to laptop via eth0

Sun Jan 20, 2013 8:24 pm

Are you saying you want to connect them without a router? If so, then it can work by declaring the ip addresses in cmdline.txt with an ip statement which says the IP addresses for both your PC and the Pi.

Too complicated to type all the details here, I have written up how to do that on following page, but ip entry would be same except for changing the addresses. Scroll down to section "On the Raspberry Pi Side" for links to threads, explanation and examples.

http://sdjf.esmartdesign.com/raspberrypi/ethernet.html

I have not been able to get ethernet working, but do know that the IP assignment is working perfectly with my usb0 connection, following instructions I posted on that page.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

DarkSotM
Posts: 1
Joined: Wed Jan 23, 2013 10:06 pm

Re: Connecting RPi to laptop via eth0

Wed Jan 23, 2013 10:08 pm

Sounds like like you need a "cross over" cable instead of a standard cat5 cable.

User avatar
scruss
Posts: 3212
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Connecting RPi to laptop via eth0

Sun Jan 27, 2013 2:11 pm

DarkSotM wrote:Sounds like like you need a "cross over" cable instead of a standard cat5 cable.
No, the ethernet port on the Raspberry Pi is auto-sensing.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Spid
Posts: 525
Joined: Sat Jan 19, 2013 12:47 pm

Re: Connecting RPi to laptop via eth0

Sun Jan 27, 2013 2:19 pm

Why not use Internet connection Sharing on the Windoze machine http://www.raspberrypi.org/phpBB3/viewt ... 36&t=31307
I will always assume you are running Raspbian for desktop and Raspbmc for XMBC !

lipka
Posts: 8
Joined: Fri Jan 18, 2013 1:00 pm

Re: Connecting RPi to laptop via eth0

Sun Jan 27, 2013 8:47 pm

ok i will try on my Arch pc so my ipconfig -a (with RPi connected) :

Code: Select all

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::219:dbff:fee0:6a64  prefixlen 64  scopeid 0x20<link>
        ether 00:19:db:e0:6a:64  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4  bytes 600 (600.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 16436
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 4  bytes 240 (240.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4  bytes 240 (240.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.5  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::ca3a:35ff:fec6:47a0  prefixlen 64  scopeid 0x20<link>
        ether c8:3a:35:c6:47:a0  txqueuelen 1000  (Ethernet)
        RX packets 8746  bytes 6231853 (5.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6563  bytes 922025 (900.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Connecting RPi to laptop via eth0

Sun Jan 27, 2013 8:57 pm

You have no IP address. You need to either set static IP addresses on both your PC and the RaspPi, or you need to run a DHCP server somewhere.

Here's my desktop ifconfig -a, see the difference?
richard@jupiter ~ $ ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:1f:d0:dd:c9:a8
inet addr:192.168.0.5 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::21f:d0ff:fedd:c9a8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2531803 errors:0 dropped:0 overruns:0 frame:0
TX packets:2059803 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2044586753 (2.0 GB) TX bytes:398352343 (398.3 MB)
Interrupt:42 Base address:0x8000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:83313 errors:0 dropped:0 overruns:0 frame:0
TX packets:83313 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:7778819 (7.7 MB) TX bytes:7778819 (7.7 MB)

lipka
Posts: 8
Joined: Fri Jan 18, 2013 1:00 pm

Re: Connecting RPi to laptop via eth0

Sun Jan 27, 2013 9:10 pm

Ok, I decide to set it static way so :

Code: Select all

ifconfig eth0 192.168.1.1 netmask 255.255.255.0 up
ifconfig :

Code: Select all

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.1  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::219:dbff:fee0:6a64  prefixlen 64  scopeid 0x20<link>
        ether 00:19:db:e0:6a:64  txqueuelen 1000  (Ethernet)
        RX packets 5  bytes 1832 (1.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 133  bytes 44718 (43.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
after reading http://sdjf.esmartdesign.com/raspberrypi/ethernet.html
i done :

Code: Select all

route add default gw 192.168.1.2 eth0
route add -host 192.168.1.2 eth0
route :

Code: Select all

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.2     0.0.0.0         UG    0      0        0 eth0
default         192.168.0.1     0.0.0.0         UG    0      0        0 wlan0
192.168.0.0     *               255.255.255.0   U     0      0        0 wlan0
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0
192.168.1.2     *               255.255.255.255 UH    0      0        0 eth0
then i add to my cmdline.txt (on RPi)
ip=192.168.1.1:192.168.1.2:192.168.1.1:255.255.255.0:rpi:eth0:off

And still i cant find my RPi...
ping 192.168.1.2
gives me nothing :/

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: Connecting RPi to laptop via eth0

Mon Jan 28, 2013 2:27 am

The way I read your IP assignment, 192.168.1.2 is the your PC, and 192.168.1.1 would be your pi.

I am not sure you did everything in the right order.

The first thing to do, if you are not using a router, is to reboot the Pi so that the IP address assignment you made in your /boot/cmdline.txt is something it knows about.

Again, my experience is more with usb0 as I had hardware issues, and gave up on ethernet, so someone correct me if I am wrong. But you need to make sure you tell both your Raspberry Pi and your PC what both IP assignments are. Doing it on one side only may not work.

And your third IP number is wrong, it has to be something else, you have given it 192.168.1.1, a friend suggested using 127.0.0.1 instead and I have not had issues with that, but the right IP for that third address might be assigned differently in eth0.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

lipka
Posts: 8
Joined: Fri Jan 18, 2013 1:00 pm

Re: Connecting RPi to laptop via eth0

Mon Jan 28, 2013 6:04 am

I would like to set ip of my pc: 192.168.1.1 and my rpi to:192.168.1. 2, so I think that I did something wrong :-\

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: Connecting RPi to laptop via eth0

Mon Jan 28, 2013 4:20 pm

I am very sorry, now that I understand this stuff better, I think I need to revise the relevant section of that page, it was very confusing about whether the Pi or the PC is the client vs. server. What I think you want is:

ip=192.168.1.2:192.168.1.1:127.0.0.1:255.255.255.0:rpi:eth0:off

Note you can pick any name you want for your Pi for this purpose. Since I have more than one Pi SD card, the different SD cards give each card a different networking name, so I can keep them straight. One is rpi4 and the other is rpi5. Otherwise, ssh complains that the authorized keys do not match, if I have all Pi cards using the same IP and networking name.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

lipka
Posts: 8
Joined: Fri Jan 18, 2013 1:00 pm

Re: Connecting RPi to laptop via eth0

Mon Jan 28, 2013 5:56 pm

Thank you a lot ;)
After change ip= line everything works ;)
I was stupid when i set ip of RPi to this same as ArchPC. My mistake.

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: Connecting RPi to laptop via eth0

Tue Jan 29, 2013 12:15 am

I am very glad that worked, but I also think that what others had told me was wrong for the Pi the way you and I need it, and I had not noticed as I was fiddling with things for so long, I did not look back at what I had written, or when I did, I did not notice the confusion. I have just revised that section to make it more clear, so it will be more helpful to everyone. I had a really hard time getting anybody to tell me which was the client and which was the server, I do not think anybody was really sure about which was which because most people do not use it the way we are doing so, to connect two devices directly with nothing in between.

that is so cool that it is working for you now! No router needed, right on!!!
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

lipka
Posts: 8
Joined: Fri Jan 18, 2013 1:00 pm

Re: Connecting RPi to laptop via eth0

Wed Jan 30, 2013 12:04 pm

Ok, but i have one more problem...
How to share internet connection from ArchPC to my RPi ?

pepedog
Posts: 1043
Joined: Fri Oct 07, 2011 9:55 am

Re: Connecting RPi to laptop via eth0

Wed Jan 30, 2013 4:58 pm

Is your archpc systemd?
Need to see your existing config on that first, ie how wlan starts up

lipka
Posts: 8
Joined: Fri Jan 18, 2013 1:00 pm

Re: Connecting RPi to laptop via eth0

Sat Feb 09, 2013 8:26 pm

Yes its systemd... what config do you need ?
Arch PC is connected to router via usb wifi card, arch use NetworkManager to connect.

pepedog
Posts: 1043
Joined: Fri Oct 07, 2011 9:55 am

Re: Connecting RPi to laptop via eth0

Sat Feb 09, 2013 9:33 pm

I would use bridge on your pc
It would mean getting rid of networkmanager and manually configuring, and pi would be back to dhcpcd again
https://wiki.archlinux.org/index.php/Bridge_with_netcfg
Where it says eth0 you put wlan0, where it says eth1 put eth0
I'm unclear how wlan0 comes up though

ugomilap
Posts: 1
Joined: Mon Feb 18, 2013 6:33 pm

Re: Connecting RPi to laptop via eth0

Mon Feb 18, 2013 7:09 pm

I'm trying to do the same thing as lipka with no luck...can someone help me?

Here's what I've done so far (trying to connect a dell using Ubuntu 11.10 to the rpi):

(1) connected the two together using an ethernet cable
(2) rpi: added static ip address (192.168.1.9) to eth0:

Code: Select all

 sudo ifconfig eth0 192.168.1.9 netmask 255.255.255.0 up 
(3) Dell:
(a) added static ip address (192.168.1.5) to eth0:

ifconfig (Dell)

Code: Select all

eth0      Link encap:Ethernet  HWaddr 00:14:22:a6:ee:13  
          inet addr:192.168.1.5  Bcast:0.0.0.0  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:17 
(b) changed routing settings

Code: Select all

route add default gw 192.168.1.9 eth0
route add -host 192.168.1.9 eth0

Code: Select all

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.9     0.0.0.0         UG    0      0        0 eth0
default         192.168.1.1     0.0.0.0         UG    0      0        0 wlan0
link-local      *               255.255.0.0     U     1000   0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     2      0        0 wlan0
192.168.1.9     *               255.255.255.255 UH    0      0        0 eth0
(4) back to rpi:
Using the link above, I added the following to /boot/cmdline.txt (then rebooted)

Code: Select all

ip=192.168.1.9:192.168.1.5:127.0.0.1:255.255.255.0:rpi:eth0:off 
Unfortunately, anytime I ping one device from the other, I get nothing but timeouts. Any idea what I'm doing wrong? Is there something else I need to change?

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: Connecting RPi to laptop via eth0

Mon Feb 18, 2013 10:57 pm

Run ifconfig on both to make sure your network is up.

What about your power supply? Can you verify that you are getting 4.75-5.25 at TP1-TP2?

I am wondering if having both wlan0 and eth0 could be messing things up.

Another thing to try installing to help figure out what is going on is tcpdump. It is in the repository, and it listens for pings (and maybe other stuff, I just use it to see when pings go through) and tells you where they are coming from.

I bet your pings are not going over ethernet for some reason.

Also, I do not recall seeing timeouts when pinging, can you post the command you enter and the output? Use the IP addresses, not host names right now.

When I ping something and it does not get through, I get output like:

Destination Host Unreachable.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: Connecting RPi to laptop via eth0

Tue Feb 19, 2013 3:41 am

Another thing - if you reboot, you have to run the ifconfig and route commands again. And make sure that ifconfig and route show the correct IPs in them right before you run your ping. I do not know if it is true for ethernet, but for my usb0 connection, it has to be reset if the other box (my PDA) loses the connection.

I have read that ssh is resilient and stays open for a few hours, but other connections can die off pretty quickly if the network seems down to either the host box or the Pi. This latter point has a been a major problem for me, resetting a connection when it gets lost, but it is not over ethernet, I am not sure if that is more resilient. But important to check it each time you try to ping, just to make sure.

I also am finding that I have to run both commands on both boxes, too, not just one of them. Once you get things working, you will just have to experiment to see which commands, if any, do not have to be repeated. I put the command sequences in scripts.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

Return to “Arch”