Macbook Pro 网线直连树莓派3

之前认为只有树莓派和电脑连接路由器,在同一个局域网内才可以连接,嫌麻烦。就发现了串口直连的方式。用mac终端直连很方便。但这种方式,对于分页显示很不爽,推着文件也很麻烦嘛,就尝试着网线直连。

没有网口,使用的绿联的Type-c扩展 ,插入电脑,在mac 系统偏好设置-网络 中显示“USB 10/100/1000 LAN”。另一根网线。

mac 系统偏好设置-共享-互联网共享,设置共享来源 WIFI,用以下端口共享给电脑,选择“USB 10/100/1000 LAN”。并启动。

Macbook Pro 网线直连树莓派3_第1张图片

此时网络 里显示开启了DHCP,自动获取的IP为169.254.*.*,现在也不知道为什么。但是先不管这个IP。

Macbook Pro 网线直连树莓派3_第2张图片

接下来,在mac 终端查询IP,ifconfig,出来一大堆,找到 bridge100:

bridge100: flags=8863 mtu 1500
	options=3
	ether  
	inet 192.168.2.1 netmask 0xffffff00 broadcast 192.168.2.255
	inet6 fe70::8c95:90ef:fdc2:9345%bridge100 prefixlen 64 scopeid 0x15 
	Configuration:
		id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
		maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
		root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
		ipfilter disabled flags 0x2
	member: en8 flags=3
	        ifmaxaddr 0 port 20 priority 0 path cost 0
	nd6 options=201
	media: autoselect
	status: active

inet一行,IP为 192.168.2.1,到此,就知道将树莓派设置成相同段的一个固定IP。由于之前就已经用串口连接,就直接登陆树莓派设置了 /etc/network/interfaces文件,添加如下红色内容。一开始不懂 lo 与 eth0的区别,一直在lo下改,树莓派上ifconfig 只有lo IP:127.0.0.1,后来才发现是要添加 eth0。

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:

source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet dhcp

auto eth0
iface eth0 inet static
address 192.168.2.4
netmask 255.255.255.0
gateway 192.168.2.1

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp

尝试了重启网络命令没成功 ,sudo /etc/init.d/networking restart,就直接下电重启了。

确保树莓派已经开启了SSH。

mac上使用破解版的SecureCRT,登陆成功,另外使用串口连接时,用SecureCRT比mac终端好用。

Macbook Pro 网线直连树莓派3_第3张图片




你可能感兴趣的:(Linux)