Connect Raspberry Pi via Ethernet to a laptop without a router?

I am working on a balloon project with a Raspberry Pi. When we potentially return the Raspberry Pi, it will most likely be in the countryside, and I would like to safely disconnect the Pi at that location.

Without a router or network nearby, I was wondering if there is a way to connect the Raspberry Pi using an Ethernet cable directly to the laptop?

+96
ssh raspberry-pi ethernet
Apr 16 '13 at 14:46
source share
10 answers

This solution is for Ubuntu (the idea also works for Windows or Mac). I just tried it today and it works like a charm.

Material

  • cross Ethernet cable (this is the name, but it is a regular Ethernet cable).
  • laptop (ubuntu)
  • Raspberry Pi (I have Pi2)

Prerequisites on your ubuntu

  1. Install network manager

    $sudo apt-get install network-manager

  2. Install nmap

    $sudo apt-get install nmap

Change wired connection on your laptop (Ubuntu)

  1. Change IpV4 settings to "Share on other computers"
  2. Save setting
  3. Reboot the laptop.

Share your laptop’s WiFi connection via Ethernet crossover

  1. Connect your RPi to your laptop using an Ethernet cable

  2. Find the broadcast address of the Ethernet connection (laptop),

$/sbin/ifconfig eth1 | grep "Bcast" | awk -F: '{print $3}' | awk '{print $1}' $/sbin/ifconfig eth1 | grep "Bcast" | awk -F: '{print $3}' | awk '{print $1}' 10.42.0.255

  • Use this address to find out the IP address of your RPi, this is 10.42.0.96 in my case, because 10.42.0.1 is my laptop

    $nmap -n -sP 10.42.0.255/24

  Starting Nmap 6.40 ( http://nmap.org ) at 2016-02-20 23:07 CET Nmap scan report for 10.42.0.1 Host is up (0.00031s latency). Nmap scan report for 10.42.0.96 Host is up (0.0023s latency). Nmap done: 256 IP addresses (2 hosts up) scanned in 2.71 seconds 
  1. Log in to your RPi from your laptop (-Y with X-forwarding)

    $ssh -Y pi@10.42.0.96

  2. Here and there! Your RPi is now connected to your laptop, and RPi can share a Wi-Fi connection.

    pi@raspberrypi ~ $

Share the display and keyboard of your laptop with RPi

  1. Install vncserver on Raspberry Pi

    $ sudo apt-get update

    $ sudo apt-get install tightvncserver

  2. Install vncviewer on your laptop by downloading RealVNC (it supports multiple platforms) http://www.realvnc.com/download/vnc/

  3. To be able to copy and paste files from the VNC ↔ VNC server, you need to install autocutsel on your RPi.

$sudo apt-get install autocutsel

If this site does not work, try downloading .deb directly from the mirror site, for example. mirror.hmc.edu/debian/pool/main/a/autocutsel/autocutsel_0.10.0-1_armhf.deb
and install it

$sudo dpkg -i autocutsel_0.10.0-1_armhf.deb

  1. Run vncserver on your RPi (you have to restart vncserver after installing autocutsel, you can issue $vncserver -kill :1 )

    $vncserver :1

  2. Add autocutsel -fork to /home/pi/.vnc/xstartup

  #!/bin/sh xrdb $HOME/.Xresources xsetroot -solid grey autocutsel -fork #x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & #x-window-manager & # Fix to make GNOME work export XKL_XMODMAP_DISABLE=1 /etc/X11/Xsession 
  1. Run vncviewer on your laptop

    $vncviewer

  2. The vncviewer window will appear and enter the IP address of your RPi (provided by your laptop), and then port 1, which is your VNC server. for example: 10.42.0.96:1 in my case.

  3. Connect it to the vncserver hosted on your RPi by entering a password (configure the password yourself)

    12. Now you can see the RPi desktop on your laptop, and I opened my browser to show that the general WiFi connection also works.

See the Raspberry Pi desktop on your ubuntu

+74
Feb 20 '16 at 22:39
source share

You do not need a crossover cable. You can use a regular network cable because the Raspberry Pi LAN chip is smart enough to reconfigure for direct network connections. Greetings

+20
Jan 19 '14 at 7:26
source share

No router + no screen + regular Ethernet cable + RPI 2 + Raspbian Lite 2018-11-13 + Ubuntu 18.10

First we need to enable the SSH server on Pi, which is disabled by default for security.

If you already have a shell for Pi through a non-SSH method, such as screen + keyboard or UART (see below), just run:

 sudo systemctl enable ssh sudo service sshd start 

as explained at: https://raspberrypi.stackexchange.com/questions/58478/ssh-not-working-with-fresh-install This is saved at boot time.

Otherwise, insert the SD card into your host and create a magic empty file called ssh file in the boot/ section.

On Ubuntu hosts, it is mounted automatically, and you can do it simply:

 sudo touch /media/$USER/boot/ssh 

which you can confirm with:

 lsblk 

which contains:

 mmcblk0 179:0 0 14.4G 0 disk ├─mmcblk0p1 179:1 0 43.9M 0 part /media/ciro/boot └─mmcblk0p2 179:2 0 14.4G 0 part /media/ciro/rootfs 

If you do not enable the SSHD daemon on the Pi, then the SSH connection will fail with:

 ssh: connect to host 10.42.0.160 port 22: Connection refused 

when we try it later.

After turning on the SSH server

Then download the Pi and connect the Ethernet cable from your laptop directly to the Pi:

enter image description here

In Ubuntu 17.04, in order to get around this error, as indicated in this answer, you first need to:

 sudo apt-get install dnsmasq-base 

On the host, open the network manager:

 nm-connection-editor 

And go:

  1. + sign (add a new connection)
  2. Ethernet
  3. Create
  4. IPv4 Settings
  5. Method: Common to other computers
  6. Set a good name for this.
  7. Save

enter image description here

Find IP Pi on the host:

 cat /var/lib/misc/dnsmasq.leases 

outputs something like:

 1532204957 b8:27:eb:0c:1f:69 10.42.0.160 raspberrypi 01:b8:27:eb:0c:1f:69 

10.42.0.160 is IP, while as usual:

 ssh pi@10.42.0.160 

I also have the following in my .bashrc :

 piip() ( cat /var/lib/misc/dnsmasq.leases | cut -d ' ' -f 3; ) pissh() ( sshpass -p raspberry ssh "pi@$(piip)"; ) 

Please note that inside the Pi, it can normally access the Internet through other interfaces of your host:

 ping google.com 

For example, on my laptop, Pi uses Ethernet, but the host is also connected to the Internet via WiFi.

A crossover cable is not required if the host network card supports Auto MDI-X . This applies to the very latest hardware, including, for example, the 2012 Lenovo T430 on which I tested, which has an "Intel® 82579LM Gigabit Network Connection" that documents support for Auto MDI-X .

Now you can also:

UART Serial USB Converter

This is an alternative to SSH if you just want to get a shell for Pi: https://en.wikipedia.org/wiki/Serial_port

It does not use SSH or the network itself, but an older one, simpler, more direct, more reliable, with lower bandwidth and shorter serial interface distance. Pi will not have access to the Internet with this method.

Desktop computers still have a serial port that can be connected directly to the network with Pi, but they are hidden in most laptops, so we need to buy a cheap USB adapter. Here I used: https://www.amazon.co.uk/gp/product/B072K3Z3TL See Also: https://unix.stackexchange.com/questions/307390/what-is-the-difference-between- ttys0 -ttyUSB0-and-ttyama0-in-Linux / 367882 # 367882

First, connect the SD card to the host and edit the config.txt file present in the first section, adding:

 enable_uart=1 

as explained at: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=141195

This first section contains the bootloader, its configuration files and the (Linux / your) kernel, config.txt is one of them. The second section contains the current root Linux file system.

Now connect your computer to the Pi as:

enter image description here

You only need to connect 3 cables:

  • Earth to earth
  • Tx Pi to Rx USB to Serial Port
  • Rx to Pi to Tx to USB to serial port

This is also documented at: https://www.raspberrypi.org/documentation/usage/gpio/README.md.

Be careful not to connect the Earth with 5 V, I already recorded 2 UART on USB and RPI UART chips, doing this!

You do not need to connect 5V to 5V at all. I think you can power your Pi this way, but I read that this is a bad idea, just use a regular USB power supply.

Finally, plug the USB connector into your host computer and get a shell with:

 sudo apt install screen sudo usermod -a -G dialout $USER screen /dev/ttyUSB0 115200 

Exit with Ctrl-A \ .

Here is a video from Adafruit showing it: https://www.youtube.com/watch?v=zUBPeoLW16Q

see also

A similar question on RPI SE: https://raspberrypi.stackexchange.com/questions/3867/ssh-to-rpi-without-a-network-connection

+17
Aug 22 '16 at 18:39
source share

I just implemented and verified this successfully. In the same situation with my project, you want to connect to a Raspberry Pi without a router or Wi-Fi. Just a simple Ethernet cable.

Using the ssh putty program, put the address as

raspberrypi.local

Log in and you can access the terminal.

Alternatively, if the VNC server is configured, use the VNC server and put

raspberrypi.local: 1

In the server address. enter the password for your VNC server and you now have access to the GUI to do what you want.

In this case, the scripts were run in a remote location. In a poster situation, safely turn off the Pi. Symptom Acne.

+8
Nov 15 '16 at 19:43
source share

Set up a static ip for your laptop and raspberry pi. On rapberryPI, configure it as follows.

 pi@rpi>sudo nano /etc/network/interfaces 

Then make the following settings to connect to the laptop.

 iface eth0 inet static address 192.168.1.81 netmask 255.255.255.0 broadcast 192.168.1.255 
+7
Apr 19 '15 at 1:02
source share

configure static ip on raspberry pi:

 sudo nano /etc/network/interfaces 

and then add:

 iface eth0 inet static address 169.254.0.2 netmask 255.255.255.0 broadcast 169.254.0.255 

then you can get your raspberries via ssh

 ssh pi@169.254.0.2 
+4
Nov 01 '15 at 18:16
source share

The following instructions are for Windows users when connecting to an RPi using only an Ethernet cable and a DHCP server. There is no need for a crossover cable, as the RPi can handle this. I have a blog post that documents this with photos here , which might be easier to follow.

Downloads

Download the DHCP server for Windows (download link here ). Unzip the zip file and open the dhcpwiz application that will configure the DHCP server.

DHCP Server Configuration

Click on the first screen.

On the second screen, find the line "Local Area Connection" and make sure that its IP address is 0.0.0.0 and its status is enabled . Connect the Ethernet cable from the RPi to the laptop and turn on the Pi. Click Refresh on this screen until the IP address changes to 169.254.*.* . If this is something else, you should change your network settings to connect over the local network (make sure that it is not static IP / DNS). Click on this line to connect to the local network and click next.

Check HTTP (Web Server) . This greatly simplifies finding the RPi's IP address. Click Next.

Take the defaults and click Next until you get to the Writing the INI file screen. Check Overwrite existing file and click the Write INI file button. Then click Next.

On the last screen, check Run DHCP server immediately and click Finish.

DHCP server and getting the IP address of your raspberry PI

This starts the actual DHCP server using the configuration just created in the previous wizard. Click the Continue as tray app button, and the DHCP server will be minimized in the taskbar.

Anywhere from 1 second to 5 minutes, you will see a warning in the taskbar with a laptop and a new RPi IP address. This warning is very quick, and you will probably miss it. Usually your RPi IP address is 169.254.0.2 , but it could be *.01 or even something else. It is easier to access the web interface of the DHCP web server at http: //localhost/dhcpstatus.xml . This will indicate the host name as "raspberrypi" with its IP address.

Now you can mask or remote desktop in your RPi, as well as configure its wireless settings or whatever you want to do.

Trouble-shooting

It can be a little tiring. I found that my connection dropped and was unable to recover SSH using the IP address. Usually I can restart the Pi and get the IP address again. Sometimes I have to restart the RPI and DHCP server. Sometimes I have to do this several times. At some point, when I did not receive the connection for 15 minutes, I copied all the files in the dhcpsrv2.5.1 folder to a new folder and tried again; he immediately worked.

+3
Apr 16 '16 at 21:10
source share

You can use ethernet cross cable - http://en.wikipedia.org/wiki/Ethernet_crossover_cable

Assuming your RPi is a DCHP client, it is best to run a simple DHCP server on your laptop to assign an RPi IP address.

+2
Apr 17 '13 at 6:46
source share

Yes, you can connect raspberries directly to a computer without a router. For this, it is necessary that raspberries and your computer are on the same subnet, and both of them have a static ip-configured (and an Ethernet cable connected between the two devices).

The ideal configuration would be as follows:

Raspberry on eth0: IP: 192.168.1.10 SubNet: 255.255.255.0

Your PC: IP: 192.168.1.11 SubNet 255.255.255.0

To set a manual IP address on raspberries, you can follow this guide.

On your PC, you can set the manual IP address in the settings of the network adapter, and the procedure depends on your operating system.

When you set up two static IP addresses, you can connect to raspberries via SSH using the IP dialing (192.168.1.10).

Another easy way is to connect a button on the GPIO to turn off raspberries! Look at here!

+1
Aug 10 '16 at 19:40
source share

A combination of answers by Nicole Finney and Ciro Santilli, as well as answers from other sources, worked for me.

Pi setting

We will need to do two things: activate ssh on pi and configure pi to use static ip.

SSH activation

Add a file named ssh to the boot partition of the sd card (not to the /boot folder on the root partition). This is well documented elsewhere.

Static IP

Open /etc/dhcpcd.conf on the pi SD card and uncomment the example for static ip (it starts near line 40). Set addresses

 # Example static IP configuration: interface eth0 static ip_address=10.42.0.182/24 static routers=10.42.0.1 static domain_name_servers=10.42.0.1 8.8.8.8 fd51:42f8:caae:d92e::1 

Customize your laptop

First, make sure your networkmanager (with a graphical interface) is installed on your laptop. Then make sure dnsmasq not working as a service:
systemctl status dnsmasq
If this command displays that the service is stopped, then everything is in order.

Next we need a networkmanager . Open /etc/NetworkManager/NetworkManager.conf and add the following two lines at the top:

 [main] DNS=dnsmasq 

Then restart your computer. This step may not be necessary. It may be sufficient to restart the NetworkManager service. Now go to the NetworkManager graphical interface (which is usually accessed by the icon in the corner of the screen) and select " Edit Connections... In the window that appears, click the + icon to create a new connection. Select Ethernet as the type and click Create... Go to IPv4 Settings tab and select the Shared to other computers method. Give the connection a good name and save.

Plug in your Raspberry Pi and make sure your laptop uses the new connection as an Ethernet connection. If so, your pi should now have the IP given to it by your computer. You can find this by running ifconfig first. This should give you several blocks of text, one for each network interface. You are interested in something like enp0s25 or eth0 . It should have a line that reads something similar to
inet 10.42.0.1 netmask 255.255.255.0 broadcast 10.42.0.255
look at the broadcast address (in this case 10.42.0.255 ). If it is different from mine, turn off the pi and insert the SD card into the laptop to change the static ip_address address of static ip_address so that the first three numbers match the broadcast address. Also replace static routers and the first of domain_name_servers with the inet address of your laptop. Turn on the pi again and plug it in. Run ifconfig times to see that the addresses have not changed.

Ssh to pi

ssh pi@10.42.0.182
If you get connection refused , pi ssh server is not working. If you get host unreachable , sorry.

Hope this helps someone!

0
Jan 26 '19 at 1:21
source share



All Articles