通过以太网将 Raspberry Pi 连接到没有路由器的笔记本电脑? [英] Hook up Raspberry Pi via Ethernet to laptop without router?

查看:16
本文介绍了通过以太网将 Raspberry Pi 连接到没有路由器的笔记本电脑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Raspberry Pi 进行气球项目.当我们有可能恢复 Raspberry Pi 时,它很可能位于农村地区,我想在那时安全地关闭 Pi.

附近没有路由器或网络,我想知道是否有办法将带有以太网电缆的 Raspberry Pi 直接连接到笔记本电脑?

解决方案

这是一个适用于 Ubuntu 的解决方案(这个想法也适用于 Windows 或 Mac),我今天刚试过,效果很好.

材料

  1. 交叉以太网电缆(名称很花哨,但它只是普通的以太网电缆)
  2. 一台笔记本电脑(ubuntu)
  3. 树莓派(我有 Pi2)

您的 ubuntu 的先决条件

  1. 安装网络管理器

    $sudo apt-get install network-manager

  2. 安装 nmap

    $sudo apt-get install nmap

在您的笔记本电脑 (Ubuntu) 上编辑有线连接

  1. 将 IpV4 设置更改为共享到其他计算机"
  2. 保存设置
  3. 重启你的笔记本电脑

通过以太网交叉电缆共享笔记本电脑的 WiFi 连接

  1. 使用以太网线将 RPi 与笔记本电脑连接

  2. 查找以太网连接(笔记本电脑)的广播地址,

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

  1. 使用这个地址来找出你的 RPi 的 IP 地址,在我的例子中是 10.42.0.96,因为 10.42.0.1 是我的笔记本电脑

    $nmap -n -sP 10.42.0.255/24

<块引用>

 在 2016-02-20 23:07 CET 开始 Nmap 6.40 ( http://nmap.org )10.42.0.1 的 Nmap 扫描报告主机已启动(0.00031 秒延迟).10.42.0.96 的 Nmap 扫描报告主机已启动(0.0023 秒延迟).Nmap 完成:256 个 IP 地址(2 个主机)在 2.71 秒内扫描

  1. 从您的笔记本电脑登录到您的 RPi(-Y 和 X 转发)

    $ssh -Y pi@10.42.0.96

  2. 瞧!现在您的 RPi 已连接到您的笔记本电脑,并且 RPi 可以共享 WiFi 连接.

    pi@raspberrypi ~ $

分享展示&带 RPi 的笔记本电脑键盘

  1. 在树莓派上安装vncserver

    $ sudo apt-get 更新

    $ sudo apt-get install tinyvncserver

  2. 通过下载 RealVNC(它支持多个平台)在您的笔记本电脑上安装 vncviewerhttp://www.realvnc.com/download/vnc/

  3. 为了能够复制&从 VNC 服务器粘贴 <--> VNC 查看器,您需要在您的 RPi 上安装 autocutsel.

$sudo apt-get install autocutsel

如果此站点无法运行,请尝试直接从镜像站点下载 .deb,例如mirror.hmc.edu/debian/pool/main/a/autocutsel/autocutsel_0.10.0-1_armhf.deb
并安装

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

  1. 在您的 RPi 上启动 vncserver(安装 autocutsel 后必须重新启动 vncserver,您可以发出 $vncserver -kill :1)

    $vncserver :1

  2. 将 autocutsel -fork 添加到/home/pi/.vnc/xstartup

<块引用>

 #!/bin/shxrdb $HOME/.Xresources xsetroot -纯灰色autocutsel -fork#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP 桌面" &#x-window-manager &# 修复以使 GNOME 工作导出 XKL_XMODMAP_DISABLE=1/etc/X11/Xsession

  1. 在您的笔记本电脑上启动 vncviewer

    $vncviewer

  2. 一个 vncviewer 窗口将弹出并输入您的 RPi 的 IP 地址(由您的笔记本电脑提供),然后是端口 1,它是您的 VNC 服务器.例如:在我的例子中是 10.42.0.96:1.

  3. 通过输入密码(自己设置密码)将其连接到 RPi 上托管的 vncserver

    12.现在您可以在笔记本电脑上看到 RPi 的桌面,我打开浏览器显示共享 WiFi 连接也正常工作.

在您的 ubuntu 上查看 Raspberry Pi 桌面

I'm working on a balloon project with a Raspberry Pi. When we potentially recover the Raspberry Pi, it will most likely be in a rural location and I'd like to turn off the Pi at that point safely.

Without a router or network nearby, I was wondering if there is a way to hook up a Raspberry Pi with an Ethernet cable directly to a laptop?

解决方案

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

Material

  1. a cross-over Ethernet cable (the name is fancy but it's just a normal Ethernet cable)
  2. a laptop (ubuntu)
  3. a Raspberry Pi (I have the Pi2)

Prerequisites on your ubuntu

  1. Install network-manager

    $sudo apt-get install network-manager

  2. Install nmap

    $sudo apt-get install nmap

Edit Wired connection on your laptop (Ubuntu)

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

Share WiFi connection of your laptop via Ethernet crossover cable

  1. Hook up your RPi with your laptop using the Ethernet cable

  2. Look up the broadcast address of the Ethernet connection (Laptop),

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

  1. Use this address to find out the IP address of your RPi, it's 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. Login to your RPi from your laptop (-Y with X-forwarding)

    $ssh -Y pi@10.42.0.96

  2. Lo and behold! Now your RPi is connected to your laptop and RPi can share the WiFi connection.

    pi@raspberrypi ~ $

Share display & 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 & paste from VNC server <--> VNC viewer, you need to install autocutsel on your RPi.

$sudo apt-get install autocutsel

If this site doesn't work, try to download the .deb directly from a mirror site, e.g. 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. Start 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. Start vncviewer on your laptop

    $vncviewer

  2. A vncviewer window will pop up and type in the IP address of your RPi (given by your laptop) followed by 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 typing in a password (set up a password yourself)

    12.Now you can see the desktop of RPi on your laptop, and I opened my browser to show the shared WiFi connection is working as well.

See Raspberry Pi desktop on your ubuntu

这篇关于通过以太网将 Raspberry Pi 连接到没有路由器的笔记本电脑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆