User avatar
cyrano
Posts: 717
Joined: Wed Dec 05, 2012 11:48 pm
Location: Belgium

Re: Connecting RPi directly to PC ethernet port

Wed Jan 09, 2013 5:36 pm

The RPi will show up in your local network because of zeroconfig. It doesn't mount as a disk because there's no SMB server running.

I think you need to set the network gateway to 0.0.0.0 because there is no gateway. A gateway is only needed if you need to connect outside of your local LAN. Setting a non-existing gateway will lead to slowdowns on the network.

cjones
Posts: 2
Joined: Thu Jan 10, 2013 4:23 am

Re: Connecting RPi directly to PC ethernet port

Thu Jan 10, 2013 4:35 am

I'm no expert in IP, but don't you need a crossover cable for this type of configuration?

User avatar
RaTTuS
Posts: 10748
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Connecting RPi directly to PC ethernet port

Thu Jan 10, 2013 10:18 am

cjones wrote:I'm no expert in IP, but don't you need a crossover cable for this type of configuration?
no - the ports are auto sensing so will work with straight cables
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

Psychaotix
Posts: 7
Joined: Fri Jan 11, 2013 2:08 pm
Location: Barossa Valley, South Australia

Re: Connecting RPi directly to PC ethernet port

Sat Jan 12, 2013 9:28 am

I know it's not exactly the same as Linux, but Windows XP and higher has the facility to bridge network connections together. This is how I temporarily run my fileserver when I need to get an important file off of it.

If the OP has a working WiFi connection to the Internet Router, then there might be some way to bridge wlan0 and eth0 together, which will allow the Pi to get a proper DHCP allocation from the DHCP server, giving it proper network access.

A google search gave this as a solution, but I don't know if it will work for you. It's commandline heavy, but since you're using SSH, it shouldn't be an issue.
http://serverfault.com/questions/405628 ... net-access

Hope that helps.

tgwaste
Posts: 51
Joined: Thu Jan 31, 2013 7:15 pm

Re: Connecting RPi directly to PC ethernet port

Fri Apr 05, 2013 3:24 am

So anyone know how I would do the reverse here?

I have a RPi connected to my router via WiFi. I want to plug my IP phone to the eth0 port of the RPi and assign it a static IP and have it access the internet as normal. Can this be done? Any advice would be appreciated.

febrifahmi
Posts: 1
Joined: Sat May 04, 2013 12:50 am

Re: Connecting RPi directly to PC ethernet port

Sat May 04, 2013 1:29 am

Hi all, I'm new here and I guess I have similar problem.. :)
hope I can get some information here..

I read the above post and I think that's a good reference for me. I have similar setup: laptop (windows 8 with 3g usb modem attached with internet connection) and RPi. I connected the RPi to the laptop directly. So far, i can PING the other device from both RPi or laptop. My configuration is:
Laptop:
ip= 192.168.137.1 (as it gets ICS from my wireless connection)
subnet mask=255.255.255.0
gateway= 192.168.137.1
dns= 10.17.125.228 (copied it from the wireless connection setting, and I'm not sure about this..)

RPi:
ip= 192.168.137.2
subnet mask=255.255.255.0
gateway= 192.168.137.1
dns= 192.168.137.1 (I'm not sure either about this)
I check the connection by connecting to the RPi via SSH (I'm running Slitaz-armhf on my pi). The connection is OK, but it seems that the pi cannot reach the internet. I tried to wget something from the internet, the pi said it can resolve the ip address but then it's failed upon connection.

Code: Select all

root@slitaz:~# wget http://distro.ibiblio.org/slitaz/packages/cooking/x11vnc-0.9
.12.tazpkg
--2012-12-01 14:14:16--  http://distro.ibiblio.org/slitaz/packages/cooking/x11vnc-0.9.12.tazpkg
Resolving distro.ibiblio.org (distro.ibiblio.org)... 152.19.134.43
Connecting to distro.ibiblio.org (distro.ibiblio.org)|152.19.134.43|:80... failed: Connection timed out.
Retrying.

--2012-12-01 14:15:21--  (try: 2)  http://distro.ibiblio.org/slitaz/packages/cooking/x11vnc-0.9.12.tazpkg
Connecting to distro.ibiblio.org (distro.ibiblio.org)|152.19.134.43|:80... ^C
root@slitaz:~#
Maybe someone know where I'm missing?

Thanks for your time.. :)
Warm regards from Indonesia..

breaker
Posts: 28
Joined: Mon May 06, 2013 6:42 am

Re: Connecting RPi directly to PC ethernet port

Tue May 07, 2013 7:44 am

If you can

Code: Select all

ping 8.8.8.8
then you are reaching the internet, if you can

Code: Select all

ping www.google.com
then your Pi can resolve domain names, if not you can add a line to /etc/resolv.conf

Code: Select all

nameserver 8.8.8.8
save /etc/resolv.conf and try

Code: Select all

ping www.google.com
again. This may not persist on a reboot, if you need that you may have to edit the dhcp configuration to not automatically obtain a DNS server.

raspipup2
Posts: 1
Joined: Mon May 20, 2013 4:16 pm

Re: Connecting RPi directly to PC ethernet port

Mon May 20, 2013 4:35 pm

My experience after read this topic:

i connect the raspberry with one usb to laptop(w7) to power it, and one ethernet cable to the same laptop(a normal ethernet cable used usually to conect pc to router)

the ip static configuration:
rapberry = 192.168.1.5 -- 255.255.255.0 -- 192.168.1.100
laptop = 192.168.1.100 -- 255.255.255.0 -- 192.168.1.100

and yet!.. run PuTTy, put the raspberry ip:
and the raspberry will asking for login and pass (like a telnet)
:D easy fast and no problems (at the first try) tnks all of yours post!

Mahouligan
Posts: 14
Joined: Sat Dec 07, 2013 12:42 am
Location: Cambridge UK

Re: Connecting RPi directly to PC ethernet port

Mon Jan 26, 2015 9:15 pm

Hi,

I didn't know whether to try starting a new topic but I've decided to try out here!

My problem started as being exactly what is described in the title: wanting to connect my RP1 to my Macbook Pro.
Reading through the entries here has got me closer I think but I am still in a knot and not quite there.
I am setting up my Pi "headless" i.e. with no keyboard or display via SSH - that part, at least is not a problem!

I have a distant (outside the house) public wifi that I am allowed to connect to. Because it is distant, I installed an Edimax EW771USN Wifi dongle (Ralink 2870 chipset) on my Macbook Pro. I was then able to connect a directional antenna to the Edimax dongle and connect with the wifi outside.

I then followed an "incredibly simple" tutorial showing how to share your mac's wifi internet connection to devices connected to its wired ethernet port. It looked as simple as turning on "Internet Sharing" on the Mac. But that didn't work for me.
Despite the fact that (I thought) I was creating two separate networks: that of the Edimax wifi and that of the world ethernet port, the two are in conflict with each other. Connecting the wired ethernet seemed to kick me off the internet. And the wired ethernet would not get an IP address from DHCP (i.e. from the PI) ... instead it has a "self-assigned IP" (says network settings on the mac)

So ... I thought I could solve the problem by connecting the Pi and Mac together via a router - (A thompson router aka O2 wireless box II is the only one I have in the house) and momentarily, I was able to ping the RPi *and* SSH into it from the Mac whilst still connected to the internet outside. But after a few minutes, and at the time of writing, I cannot still do those things.

The goal, what I need to set up the RPi, is to connect to the internet through my Macbook.

I attach an image of the netstat -nr output from my Mac ... I have been using this and other things during the learning process but as yet (I must admit) I only understand a very small proportion of the output.

Many thanks for looking
Screen Shot 2015-01-26 at 22.03.10.jpg
netstat -nr on my Macbook Pro
Screen Shot 2015-01-26 at 22.03.10.jpg (44.18 KiB) Viewed 3113 times

Mahouligan
Posts: 14
Joined: Sat Dec 07, 2013 12:42 am
Location: Cambridge UK

Re: Connecting RPi directly to PC ethernet port

Mon Jan 26, 2015 9:37 pm

Further to my post just now, I want to add some other bits of information about my setup:

These are the settings of the Edimax wireless, as seen from my Macs network settings
192.168.13.201 IP
255.255.255.0 MASK
192.168.13.254 ROUTER
10.54.51.1 DNS
These are provided by DHCP by the wifi provider outside and I havent attempted to change anything here.

These are the settings of the Rpi, as seen by my iSSH connection to it from Ipad (wirelessly via Thompson router)
192.168.1.66 IP
192.168.1.255 BCAST
255.255.255.0 MASK

The Thompson router, also seen from the Ipad nut using Safari web browser shows:
The Ipad connected by wifi on 192.168.1.65
The Rpi connected to Ethernet port 1 on 192.168.1.66
The Macbook connected to Ethernet port 4 on 192.168.1.68

The Ethernet settings from the Macbook do not correspond or make sense and it has a "self assigned IP" despite being set to DHCP:
169.254.109.37 IP
255.255.0.0 MASK
------------- ROUTER
10.54.51.1 DNS

Internet sharing in "on" on the Macbook:
Share your connection from : 802.11 n WLAN (this is the name given to the Edimax wireless)
To computers using : Ethernet


Mahouligan
Posts: 14
Joined: Sat Dec 07, 2013 12:42 am
Location: Cambridge UK

Re: Connecting RPi directly to PC ethernet port

Tue Jan 27, 2015 1:45 pm

@drgeoff - Many thanks, I followed Martin Gales excellent blog and have had an enjoyable morning of it. But still, I am not quite there:
* The Pi is connected by one ethernet cable to the Mac
* The Mac is connected to the internet by my (external) wifi dongle.
( This is real progress !)

But ...
There is still the fundamental problem that the new wifi (Ediamx) and there ethernet seem to fight each other. Whilst writing this, the ethernet stopped working to the RPi and I got it back by turning the Edimax off, the ethernet off (both in Mac settings) then ethernet back on *and* had to unplug and reconnect the ethernet cable before I could ssh the RPi again.
I cannot ping the outside world from Terminal on the Mac or from the Pi - I tried 8.8.8.8.and 8.8.4.4. Particularly puzzling since I can surf internet from Safari on the Mac.
I tried also to update raspi-config from my ssh session in a terminal window on the mac. It seemed to be downloading something but had "temporary failure resolving" various addresses. I could not tell what was actually happening. This is the output:
Err http://raspberrypi.collabora.com wheezy Release.gpg
Temporary failure resolving 'raspberrypi.collabora.com'
Err http://archive.raspberrypi.org wheezy Release.gpg
Temporary failure resolving 'archive.raspberrypi.org'
Err http://mirrordirector.raspbian.org wheezy Release.gpg
Temporary failure resolving 'mirrordirector.raspbian.org'
Reading package lists... Done
W: Failed to fetch http://mirrordirector.raspbian.org/rasp ... elease.gpg Temporary failure resolving 'mirrordirector.raspbian.org'

W: Failed to fetch http://raspberrypi.collabora.com/dists/ ... elease.gpg Temporary failure resolving 'raspberrypi.collabora.com'

W: Failed to fetch http://archive.raspberrypi.org/debian/d ... elease.gpg Temporary failure resolving 'archive.raspberrypi.org'

W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists... Done
Building dependency tree
Reading state information... Done
raspi-config is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.


I would hugely appreciate any tips even just directions for diagnosis as I have no idea what is wrong at the moment. I realise that it may not be a Raspberry problem as such, I might have got my Mac into a horrible knot. Or there might be some unknown security thing with the public wifi outside (which does issue a code for 7 days free use then only allow this use from one device etc ...)

So here below is what I have done this morning. I also have taken a desktop photo showing output from both Mac and Rpi of commands ifconfig and netstat -nr whilst everything was working ( which is a rare and difficult condition at present ! )

Following Martin Gales Blog to directly connect RPi to Mac and share its wifi internet

I used different IP addresses because my (very poor) Thompson router will only accept IP addresses in its expected range and I wanted to be able to get back into the RPi 'headlessly' if things didn't work. The router plus an iPad are my only way in to the RPi until the Mac way works.

I set Mac ethernet settings as follows:

192.168.1.200. IP
255.255.255.0 Mask
No router
10.54.51.1 DNS (this one is from the working internet wifi settings)
208.67.222.222 openDNS
208.67.220.220 openDNS

I set the Rpi up (via ssh from Ipad via router) as follows:

*** hashed out 3 lines in /etc/resolv.conf and added the IP of the Mac as 'name server'
~ $ cat /etc/resolv.conf
# this was the setup when connected to Thompson router
# domain lan
# search lan
# nameserver 192.168.1.254

nameserver 192.168.1.200

*** RPi ethernet settings in /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.1.66
netmask 255.255.255.0
gateway 192.168.1.200

Then, wanting to take things one step at a time:

*** I tuned off the Edimax wifi
>>>The ethernet connection to RPi is fine and I logged in ssh
>>>But, most bizarrely, the Mac is still connected to wifi and internet despite showing all connections turned off in settings

*** I turned on the Edimax wifi, fingers crossed
>>>It shows "Unknown state" in Mac settings (this is the first time I have seen this message for the wifi)

*** I turned off the ethernet to get the Edimax wifi back
>>>wifi signal meter is good but no reconnection until I close the Mac network preferences pane and OK the "commit to changes?"

*** I turned ethernet back on
>>> "Unknown state" but clicking "Apply " on the network preferences pane turns it on.

I finally got both wifi and ethernet on and ssh’ed into the pi to do ifconfig and netstat -nr on both whilst both were working. It illustrated how much the two really do not want to be working at the same time: I had to start / restart plug / unplug most things and restart the mac to get everything working together.
Screen Shot 2015-01-27 at 13.59.58.jpg
output from ifconfig and netstat -nr on my Rpi and Mac
Screen Shot 2015-01-27 at 13.59.58.jpg (42.86 KiB) Viewed 3033 times

Mahouligan
Posts: 14
Joined: Sat Dec 07, 2013 12:42 am
Location: Cambridge UK

Re: Connecting RPi directly to PC ethernet port

Tue Jan 27, 2015 1:54 pm

Sorry that photo is useless I know I will just copy / paste ....

ifconfig from the RPi
eth0 Link encap:Ethernet HWaddr b8:27:eb:67:aa:e8
inet addr:192.168.1.66 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:137 errors:0 dropped:0 overruns:0 frame:0
TX packets:84 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11037 (10.7 KiB) TX bytes:11467 (11.1 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:380 (380.0 B) TX bytes:380 (380.0 B)

netstat -nr from the RPi
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.1.200 0.0.0.0 UG 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

ifconfig from my mac
ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=3<RXCSUM,TXCSUM>
inet6 ::1 prefixlen 128
inet 127.0.0.1 netmask 0xff000000
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
nd6 options=1<PERFORMNUD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=2b<RXCSUM,TXCSUM,VLAN_HWTAGGING,TSO4>
ether 00:1f:5b:ec:c6:fa
inet6 fe80::21f:5bff:feec:c6fa%en0 prefixlen 64 scopeid 0x4
inet 192.168.1.200 netmask 0xffffff00 broadcast 192.168.1.255
nd6 options=1<PERFORMNUD>
media: autoselect (100baseTX <full-duplex,flow-control>)
status: active
en4: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 80:1f:02:ab:cb:f2
inet6 fe80::821f:2ff:feab:cbf2%en4 prefixlen 64 scopeid 0x5
inet 192.168.13.201 netmask 0xffffff00 broadcast 192.168.13.255
nd6 options=1<PERFORMNUD>
media: autoselect
status: active
fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 4078
lladdr 00:1f:f3:ff:fe:10:a7:ba
nd6 options=1<PERFORMNUD>
media: autoselect <full-duplex>
status: inactive
en1: flags=8823<UP,BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 1500
ether 00:21:e9:e2:80:25
nd6 options=1<PERFORMNUD>
media: autoselect (<unknown type>)
status: inactive

netstat -nr from my Mac
Sorry the rotten formatting ... this is why I tried a photo!

Routing tables

Internet:
Destination Gateway Flags Refs Use Netif Expire
default 192.168.13.254 UGSc 14 0 en4
default link#4 UCSI 3 0 en0
10.54.51.1 link#4 UHLWI 0 5 en0
127 127.0.0.1 UCS 0 0 lo0
127.0.0.1 127.0.0.1 UH 4 243 lo0
169.254 link#5 UCS 0 0 en4
169.254 link#4 UCSI 0 0 en0
192.168.1 link#4 UCS 2 0 en0
192.168.1.66 b8:27:eb:67:aa:e8 UHLWIi 1 141 en0 1096
192.168.1.200/32 link#4 UCS 1 0 en0
192.168.1.255 ff:ff:ff:ff:ff:ff UHLWbI 0 18 en0
192.168.13 link#5 UCS 1 0 en4
192.168.13.201/32 link#5 UCS 1 0 en4
192.168.13.254/32 link#5 UCS 1 0 en4
192.168.13.254 24:a4:3c:42:b6:6b UHLWIir 10 0 en4 1174
192.168.13.255 ff:ff:ff:ff:ff:ff UHLWbI 0 18 en4
208.67.220.220 link#4 UHLWI 0 4 en0
208.67.222.222 link#4 UHLWI 0 4 en0

Internet6:
Destination Gateway Flags Netif Expire
::1 ::1 UHL lo0
fe80::%lo0/64 fe80::1%lo0 UcI lo0
fe80::1%lo0 link#1 UHLI lo0
fe80::%en0/64 link#4 UCI en0
fe80::21f:5bff:feec:c6fa%en0 0:1f:5b:ec:c6:fa UHLI lo0
fe80::%en4/64 link#5 UCI en4
fe80::821f:2ff:feab:cbf2%en4 80:1f:2:ab:cb:f2 UHLI lo0
ff01::%lo0/32 ::1 UmCI lo0
ff01::%en0/32 link#4 UmCI en0
ff01::%en4/32 link#5 UmCI en4
ff02::%lo0/32 ::1 UmCI lo0
ff02::%en0/32 link#4 UmCI en0
ff02::%en4/32 link#5 UmCI en4

Mahouligan
Posts: 14
Joined: Sat Dec 07, 2013 12:42 am
Location: Cambridge UK

Re: Connecting RPi directly to PC ethernet port

Tue Jan 27, 2015 2:04 pm

I have just established that it is the turning on of internet sharing that kills it dead:

I can get wifi on (=browsing no problem on Safari on the Mac) *and* stable connection via ethernet to the RPi (an ssh session in terminal window)

But as soon as I turn Mac internet sharing on, the ssh session stops, eventually saying "broken pipe" and the RPi is no longer pinball from the Mac.

This time at least, the cure was:
* Turn off internet sharing
* Unplug and replug ethernet cable from the RPi

Return to “Advanced users”