3.Linux 网络相关

3.Linux 网络相关命令

记录开发板常见的网络命令

在linux中默认网卡为ens33

在嵌入式linux中默认网卡为eth0 eth1

makefile 复制代码
//设置ip地址为192.168.1.156
sudo ifconfig ens33 192.168.5.10
    
//启动
ifconfig eth0 up
//关闭
ifconfig eth0 down
//重启
ifconfig eth0 reload

//ping
ping www.baidu.com

//指定自己的ip去ping
ping -I 192.168.1.11 www.baidu.com
//指定eth1网络去ping
ping www.baidu.com -I eth1

//设置wlan0的ip地址和子网掩码
ifconfig wlan0 192.168.1.11 netmask 255.255.255.0
ifconfig eth0 192.168.1.123 netmask 255.255.255.0
//设置DNS
vi /etc/resolv.conf
//添加以下内容
nameserver 114.114.114.114
nameserver 192.168.3.1     //自己的网关
//保存退出重启

udhcpc -i wlan0

route   //查看路由

添加DNS服务地址

c 复制代码
echo "nameserver 114.114.114.114" > /etc/resolv.conf

或者

vi /etc/resolv.conf

复制代码
nameserver 114.114.114.114
nameserver 192.168.3.1     //自己的网关

重启

网络测试工具

ubuntu下载后作为服务器端

c 复制代码
sudo apt-get install iperf3
iperf3 -s

开发板作为客户端,192.168.1.15为ubuntu的ip地址

c 复制代码
iperf3 -c 192.168.1.15 -i 1
c 复制代码
Connecting to host 192.168.1.15, port 5201
[  4] local 192.168.1.103 port 41794 connected to 192.168.1.15 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec  11.7 MBytes  98.0 Mbits/sec    0    232 KBytes
[  4]   1.00-2.00   sec  11.2 MBytes  93.8 Mbits/sec    0    232 KBytes
[  4]   2.00-3.00   sec  11.2 MBytes  93.8 Mbits/sec    0    232 KBytes
[  4]   3.00-4.00   sec  11.2 MBytes  94.3 Mbits/sec    0    232 KBytes
[  4]   4.00-5.00   sec  11.3 MBytes  94.9 Mbits/sec    0    232 KBytes
[  4]   5.00-6.00   sec  11.2 MBytes  93.8 Mbits/sec    0    232 KBytes
[  4]   6.00-7.00   sec  11.2 MBytes  94.4 Mbits/sec    0    232 KBytes
[  4]   7.00-8.00   sec  11.1 MBytes  93.3 Mbits/sec    0    232 KBytes
[  4]   8.00-9.00   sec  11.3 MBytes  94.9 Mbits/sec    0    232 KBytes
[  4]   9.00-10.00  sec  11.2 MBytes  93.8 Mbits/sec    0    232 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec   113 MBytes  94.5 Mbits/sec    0             sender
[  4]   0.00-10.00  sec   112 MBytes  94.0 Mbits/sec                  receiver

iperf Done.

NAT模式:

桥接模式

1.控制面板\网络和 Internet\网络连接

本机网络没有任何问题,但是虚拟机不能上网,采取下面措施:

可以出现问题时对VMnet1 和VMnet8 禁用后重启,即可上网

对以太网共享给以太网6用于开发板的上网功能

方法一:

对于校园网环境:准备两根网线

开发板一根网线用于和其他网络设备进行通信,此时不能上网

另外一根用于上网,等待eth1网卡获得IP后,就可以访问外网了

c 复制代码
udhcpc -i  eth1

方法二:使用以太网的网络共享,这样默认主机地址为192.168.137.1

在开发板上重启eth0网卡即可 down / up

给linux系统添加两个网卡分别是nat 和 桥接

配置第一个网卡为用于上网

配置第二个网卡用于通信

添加网络ens37用于和外部usb设备进行连接

选择刚新添加的网络

配置其ip地址

2.在linux中专门有配置网络相关的app

linux没有网络

查看linux的外设(u盘)

c 复制代码
alientek@Ubuntu16:~$ ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sdb  /dev/sdb1
alientek@Ubuntu16:~$ 

sd表示是SATA硬盘或者其它外部设备

sda表示磁盘一 其下分区有一个sda1

sdb是我插入的U盘,下面也有一个分区sdb1

**若出现以下情况:能识别到,但无法连接

解决办法:

因为每个人安装的路径是不一样的哦,打开虚拟机的安装位置,找到后缀.vmx的文件,其实就是你操作系统(如ubuntu)安装的位置,记得打开文件的后缀名。打开后将属性 usb.restrictions.defaultAllow 由 FALSE 修改为 TRUE,保存然后启动 vm 就正常了。

相关推荐
wj3055853787 小时前
课程 9:模型测试记录与 Prompt 策略
linux·人工智能·python·comfyui
星寂樱易李7 小时前
iperf3 + Python-- 网络带宽、网速、网络稳定性
开发语言·网络·python
abigriver7 小时前
打造 Linux 离线大模型级语音输入法:Whisper.cpp + 3090 显卡加速与 Rime 中英混输终极调优指南
linux·运维·whisper
wangqiaowq8 小时前
windows下nginx的安装
linux·服务器·前端
YYRAN_ZZU8 小时前
Petalinux新建自动脚本启动
linux
charlie1145141919 小时前
嵌入式Linux驱动开发pinctrl篇(1)——从寄存器到子系统:驱动演进之路
linux·运维·驱动开发
Agent手记9 小时前
异常考勤智能预警与处理与流程优化方案 | 基于企业级Agent的超自动化实战教程
运维·人工智能·ai·自动化
于小猿Sup9 小时前
VMware在Ubuntu22.04驱动Livox Mid360s
linux·c++·嵌入式硬件·自动驾驶
cen__y9 小时前
Linux12(Git01)
linux·运维·服务器·c语言·开发语言·git
chao18984410 小时前
STM32 HAL库驱动AT24C02 EEPROM例程
stm32·单片机·嵌入式硬件