开发板通过网线连接电脑而上网

2024-04-24 22:52

本文主要是介绍开发板通过网线连接电脑而上网,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

简介

关闭win11的防火墙(之前不关也可以的,很奇怪)
一句话:!!!dhcp能自动分配IP即可联通外网!!!
原理也不懂,或许有其他方法也不清楚,但只要在/etc/netplan/01-netcfg.yaml设置dhcp: true利用netplan自动分配ip则可解决所有ping外网不通、git访问不了,apt-get出现Err:1 http://mirrors.163.com/ubuntu-ports focal InRelease Temporary failure resolving 'mirrors.163.com'错误等等问题.

电脑WIFI共享给网口

在这里插入图片描述

在这里插入图片描述

route

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         orange.mshome.n 0.0.0.0         UG    100    0        0 eth0
link-local      0.0.0.0         255.255.0.0     U     1000   0        0 eth0
192.168.137.0   0.0.0.0         255.255.255.0   U     100    0        0 eth0
192.168.137.0   0.0.0.0         255.255.255.0   U     100    0        0 eth0

link
路由表的问题

/etc/netplan/01-netcfg.yaml

# this file describes the network interfaces available on your system
# For more information, see netplan(5).
network:version: 2renderer: NetworkManager# renderer: networkdethernets:eth0:dhcp4: trueaddresses: [192.168.137.23/24]gateway4: 192.168.137.1nameservers:addresses: [114.114.114.114, 192.168.137.1]

设置dhcp: true利用netplan自动分配ip的同时设置一个静态ip来实现ssh访问,而不用每次都是用串口来查看ip才能登录。
link:

  • 1
  • 2
  • 3
  • 校园网:(1) (2)

/etc/resolv.conf

自动生成的,dhcp不能分配IP时添加常见的DNS都不行!!

# Generated by NetworkManager
search mshome.net
nameserver 127.0.0.53

/etc/systemd/resolved.conf

#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details[Resolve]
DNS=114.114.114.114
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#DNSOverTLS=no
#Cache=yes
#DNSStubListener=yes
#ReadEtcHosts=yes

虚拟机

若想虚拟机ping开发板,参考这个应该可以。

测试

开启win11防火墙

重新开启防火墙,reboot重启开发板

# # # 查看ifconfig 没问题 # # # 
root@rong-virtual-machine:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500inet 192.168.137.155  netmask 255.255.255.0  broadcast 192.168.137.255ether 00:22:33:44:55:66  txqueuelen 1000  (Ethernet)RX packets 115  bytes 20392 (20.3 KB)RX errors 0  dropped 13  overruns 0  frame 0TX packets 117  bytes 13373 (13.3 KB)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0device interrupt 87  base 0x2000lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536inet 127.0.0.1  netmask 255.0.0.0loop  txqueuelen 1000  (Local Loopback)RX packets 248  bytes 19900 (19.9 KB)RX errors 0  dropped 0  overruns 0  frame 0TX packets 248  bytes 19900 (19.9 KB)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
# # # 155为dhcp分配的ip 23为设置的静态ip # # #
root@rong-virtual-machine:~# hostname -I
192.168.137.155 192.168.137.23
# # # ping外网ip # # #
root@rong-virtual-machine:~# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=100 time=70.1 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=100 time=76.1 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=100 time=70.9 ms
^C
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 70.093/72.364/76.065/2.639 ms
# # # ping百度域名 # # #
root@rong-virtual-machine:~# ping www.baidu.com
PING www.a.shifen.com (120.232.145.185) 56(84) bytes of data.
64 bytes from 120.232.145.185 (120.232.145.185): icmp_seq=1 ttl=51 time=10.3 ms
64 bytes from 120.232.145.185 (120.232.145.185): icmp_seq=2 ttl=51 time=13.4 ms
64 bytes from 120.232.145.185 (120.232.145.185): icmp_seq=3 ttl=51 time=11.6 ms
^C
--- www.a.shifen.com ping statistics ---
4 packets transmitted, 3 received, 25% packet loss, time 9272ms
rtt min/avg/max/mdev = 10.289/11.751/13.409/1.281 ms

😨 😨 😨 居然没问题 😨 😨 😨

自测(插回电脑网口)

怀疑是电脑网口坏了,折腾了两天都不行,换到拓展坞的网口上,吃了个饭回来就好了😢 😢 😢
简介中的图片所示的以太网 2即拓展坞网口
更改为电脑上的以太网
在这里插入图片描述
重启开发板

root@rong-virtual-machine:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500inet 192.168.137.207  netmask 255.255.255.0  broadcast 192.168.137.255ether 00:22:33:44:55:66  txqueuelen 1000  (Ethernet)RX packets 93  bytes 14302 (14.3 KB)RX errors 0  dropped 13  overruns 0  frame 0TX packets 81  bytes 8422 (8.4 KB)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0device interrupt 87  base 0x2000lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536inet 127.0.0.1  netmask 255.0.0.0loop  txqueuelen 1000  (Local Loopback)RX packets 184  bytes 14969 (14.9 KB)RX errors 0  dropped 0  overruns 0  frame 0TX packets 184  bytes 14969 (14.9 KB)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0root@rong-virtual-machine:~# hostname -I
192.168.137.207
root@rong-virtual-machine:~# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=100 time=71.7 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=100 time=71.0 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=100 time=76.4 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=100 time=71.9 ms
^C
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 71.020/72.746/76.352/2.108 ms
root@rong-virtual-machine:~# ping www.baidu.com
PING www.a.shifen.com (120.232.145.144) 56(84) bytes of data.
64 bytes from 120.232.145.144: icmp_seq=1 ttl=51 time=13.6 ms
64 bytes from 120.232.145.144: icmp_seq=2 ttl=51 time=14.1 ms
64 bytes from 120.232.145.144: icmp_seq=3 ttl=51 time=12.1 ms
64 bytes from 120.232.145.144: icmp_seq=4 ttl=51 time=11.6 ms
^C
--- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 12028ms
rtt min/avg/max/mdev = 11.586/12.857/14.089/1.029 ms

其中

root@rong-virtual-machine:~# hostname -I
192.168.137.207

只显示一个ip了,netplan配置文件中的静态ip没了

无静态ip

尝试执行netplan apply,静态ip生效,但是另一个又变回之前的155了 😳 😳 😳

root@rong-virtual-machine:~# netplan apply
root@rong-virtual-machine:~# hostname -I
192.168.137.155 192.168.137.23

老天爷 为什么 😭 😭 😭
what can I say!!

再次reboot

再次重启开发板

root@rong-virtual-machine:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500inet 192.168.137.155  netmask 255.255.255.0  broadcast 192.168.137.255ether 00:22:33:44:55:66  txqueuelen 1000  (Ethernet)RX packets 96  bytes 14248 (14.2 KB)RX errors 0  dropped 12  overruns 0  frame 0TX packets 90  bytes 9701 (9.7 KB)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0device interrupt 87  base 0x2000lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536inet 127.0.0.1  netmask 255.0.0.0loop  txqueuelen 1000  (Local Loopback)RX packets 184  bytes 15321 (15.3 KB)RX errors 0  dropped 0  overruns 0  frame 0TX packets 184  bytes 15321 (15.3 KB)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0root@rong-virtual-machine:~# hostname -I
192.168.137.155 192.168.137.200 192.168.137.23

出现了3个ip
执行netplan apply

root@rong-virtual-machine:~# netplan apply
root@rong-virtual-machine:~# hostname -I
192.168.137.155 192.168.137.23
root@rong-virtual-machine:~#

无敌了。兄弟 😮 😮 😮

开发板断电

root@rong-virtual-machine:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500inet 192.168.137.155  netmask 255.255.255.0  broadcast 192.168.137.255ether 00:22:33:44:55:66  txqueuelen 1000  (Ethernet)RX packets 167  bytes 23894 (23.8 KB)RX errors 0  dropped 11  overruns 0  frame 0TX packets 156  bytes 15179 (15.1 KB)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0device interrupt 87  base 0x2000lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536inet 127.0.0.1  netmask 255.0.0.0loop  txqueuelen 1000  (Local Loopback)RX packets 38  bytes 3871 (3.8 KB)RX errors 0  dropped 0  overruns 0  frame 0TX packets 38  bytes 3871 (3.8 KB)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0root@rong-virtual-machine:~# hostname -I
192.168.137.155 192.168.137.71 192.168.137.23
root@rong-virtual-machine:~# netplan apply
root@rong-virtual-machine:~# hostname -I
192.168.137.155 192.168.137.23

搞不懂了 😦 😦 😦

可以上网

root@rong-virtual-machine:~# wget zhihu.com
--2024-04-24 21:21:36--  http://zhihu.com/
Resolving zhihu.com (zhihu.com)... 103.41.167.234
Connecting to zhihu.com (zhihu.com)|103.41.167.234|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://www.zhihu.com/ [following]
--2024-04-24 21:21:36--  https://www.zhihu.com/
Resolving www.zhihu.com (www.zhihu.com)... 120.240.101.173, 111.45.69.246, 183.240.47.143, ...
Connecting to www.zhihu.com (www.zhihu.com)|120.240.101.173|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: //www.zhihu.com/signin?next=%2F [following]
--2024-04-24 21:21:36--  https://www.zhihu.com/signin?next=%2F
Reusing existing connection to www.zhihu.com:443.
HTTP request sent, awaiting response... 200 OK
Length: 40094 (39K) [text/html]
Saving to: ‘index.html’index.html          100%[===================>]  39.15K  --.-KB/s    in 0.1s2024-04-24 21:21:37 (271 KB/s) - ‘index.html’ saved [40094/40094]

断电后拔插网线

这篇关于开发板通过网线连接电脑而上网的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/933058

相关文章

闲置电脑也能活出第二春?鲁大师AiNAS让你动动手指就能轻松部署

对于大多数人而言,在这个“数据爆炸”的时代或多或少都遇到过存储告急的情况,这使得“存储焦虑”不再是个别现象,而将会是随着软件的不断臃肿而越来越普遍的情况。从不少手机厂商都开始将存储上限提升至1TB可以见得,我们似乎正处在互联网信息飞速增长的阶段,对于存储的需求也将会不断扩大。对于苹果用户而言,这一问题愈发严峻,毕竟512GB和1TB版本的iPhone可不是人人都消费得起的,因此成熟的外置存储方案开

W外链微信推广短连接怎么做?

制作微信推广链接的难点分析 一、内容创作难度 制作微信推广链接时,首先需要创作有吸引力的内容。这不仅要求内容本身有趣、有价值,还要能够激起人们的分享欲望。对于许多企业和个人来说,尤其是那些缺乏创意和写作能力的人来说,这是制作微信推广链接的一大难点。 二、精准定位难度 微信用户群体庞大,不同用户的需求和兴趣各异。因此,制作推广链接时需要精准定位目标受众,以便更有效地吸引他们点击并分享链接

怎么让1台电脑共享给7人同时流畅设计

在当今的创意设计与数字内容生产领域,图形工作站以其强大的计算能力、专业的图形处理能力和稳定的系统性能,成为了众多设计师、动画师、视频编辑师等创意工作者的必备工具。 设计团队面临资源有限,比如只有一台高性能电脑时,如何高效地让七人同时流畅地进行设计工作,便成为了一个亟待解决的问题。 一、硬件升级与配置 1.高性能处理器(CPU):选择多核、高线程的处理器,例如Intel的至强系列或AMD的Ry

Java 连接Sql sever 2008

Java 连接Sql sever 2008 /Sql sever 2008 R2 import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class TestJDBC

实例:如何统计当前主机的连接状态和连接数

统计当前主机的连接状态和连接数 在 Linux 中,可使用 ss 命令来查看主机的网络连接状态。以下是统计当前主机连接状态和连接主机数量的具体操作。 1. 统计当前主机的连接状态 使用 ss 命令结合 grep、cut、sort 和 uniq 命令来统计当前主机的 TCP 连接状态。 ss -nta | grep -v '^State' | cut -d " " -f 1 | sort |

【Go】go连接clickhouse使用TCP协议

离开你是傻是对是错 是看破是软弱 这结果是爱是恨或者是什么 如果是种解脱 怎么会还有眷恋在我心窝 那么爱你为什么                      🎵 黄品源/莫文蔚《那么爱你为什么》 package mainimport ("context""fmt""log""time""github.com/ClickHouse/clickhouse-go/v2")func main(

nginx长连接的问题

转自: http://www.360doc.com/content/12/1108/17/1073512_246644318.shtml

NGINX轻松管理10万长连接 --- 基于2GB内存的CentOS 6.5 x86-64

转自:http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=190176&id=4234854 一 前言 当管理大量连接时,特别是只有少量活跃连接,NGINX有比较好的CPU和RAM利用率,如今是多终端保持在线的时代,更能让NGINX发挥这个优点。本文做一个简单测试,NGINX在一个普通PC虚拟机上维护100k的HTTP

TL-Tomcat中长连接的底层源码原理实现

长连接:浏览器告诉tomcat不要将请求关掉。  如果不是长连接,tomcat响应后会告诉浏览器把这个连接关掉。    tomcat中有一个缓冲区  如果发送大批量数据后 又不处理  那么会堆积缓冲区 后面的请求会越来越慢。

开发板NFS挂载文件目录

文章目录 序NFS1. 安装 NFS 服务器和客户端在服务器上(NFS 服务器端)在客户端上(NFS 客户端) 2. 配置 NFS 服务器创建共享目录编辑 `/etc/exports` 文件启动 NFS 服务 3. 在客户端挂载 NFS 共享创建挂载点挂载 NFS 共享验证挂载 4. 设置开机自动挂载5. 解决权限问题 序 本节主要实现虚拟机(服务器)与开发板(客户端)通过N