PC 和 树莓派如果不是千兆互连,那 Samba 服务器就没有啥意义了。然而我手里没有千兆路由器,这种情况下,可以使用网线直接连接树莓派和电脑,以此来实现树莓派和电脑间的千兆网络。
步骤
Raspbian 系统,编辑 /etc/dhcpcd.conf
:
1 2 3 |
interface eth0 static ip_address=10.0.0.2/24 nogateway |
win10 设置同网段IP,比如 10.0.0.3
,连不上时可尝试 禁用该网络适配器然后在启用
Ubuntu Server 上,通过 netplan 设置有线网络。编辑 /etc/netplan
,ethernetes 部分是以太网配置示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
network: wifis: wlan0: dhcp4: true access-points: "ssid": password: "password" ethernets: eth0: dhcp4: false addresses: - 10.0.0.2/24 optional: true version: 2 |
执行 netplan --debug apply
应用配置,会自动启动 netplan.wpa@wlan0.service
带宽测试
使用 iperf。Windows 系统上可以用 msys2 里的 iperf
1 2 3 4 5 6 7 |
# raspbian 服务端 sudo apt install iperf iperf -s # windows 客户端,使用msys2 pacman -S iperf iperf -c raspbian-ip |
存在的问题
2020.6.26 Update:此问题已解决,详见:https://www.annhe.net/article-4504.html。
PC ping 树莓派可能会出现丢包,一般出现在电脑重启后,和树莓派建立连接出了问题,考虑用以下方法测试:
- 检查
/var/log/messages
确定eth0
是否最近到link up
状态 nmap -sn pc_ip
检查pc是否在线
树莓派上执行 ifconfig eth0 down
, ifconfig eth0 up
,重启 eth0 之后一般就恢复了。Windows 上可能也需要重启对应的网络适配器。
最好的方法,应该是换个全千兆的路由器吧。贫穷如我,一直没舍得换。
发表回复