打开主菜单

Wiki-Orange Pi β

以太网口测试

1) 首先将网线的一端插入开发板的以太网接口,网线的另一端接入路由器,并确保网络是畅通的

2) 系统启动后会通过 DHCP 自动给以太网卡分配 IP 地址,不需要其他任何配置

3) 在开发板的 Linux 系统中查看 IP 地址的命令如下所示

orangepi@orangepi:~$ ip addr show eth0

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000

link/ether 4a:fe:2b:3d:17:1c brd ff:ff:ff:ff:ff:ff
inet 192.168.1.150/24 brd 192.168.1.255 scope global dynamic noprefixroute eth0
valid_lft 43150sec preferred_lft 43150sec
inet6 fe80::9a04:3703:faed:23be/64 scope link noprefixroute
valid_lft forever preferred_lft forever
当使用 ifconfig 查看 IP 地址时,如果提示下面的信息,是因为没有加 sudo 导致的,正确的命令是:sudo ifconfig

orangepi@orangepi:~$ ifconfig
Command 'ifconfig' is available in the following places
*/sbin/ifconfig
*/usr/sbin/ifconfig
The command could not be located because '/sbin:/usr/sbin' is not included in the PATH environment variable.
This is most likely caused by the lack of administrative privileges associated with your user account.
ifconfig: command not found

开发板启动后查看 IP 地址有三种方法:

1. 接 HDMI 显示器,然后登录系统使用 ip addr show eth0 命令查看 IP 地址
2. 在调试串口终端输入 ip addr show eth0 命令来查看 IP 地址
3. 如果没有调试串口,也没有 HDMI 显示器,还可以通过路由器的管理界面来查看开发板网口的 IP 地址。不过这种方法经常有人会无法正常看到开发板的 IP 地址。如果看不到,调试方法如下所示:
A) 首先检查 Linux 系统是否已经正常启动,如果开发板的绿灯在闪烁了,一般是正常启动了,如果只亮红灯,说明系统都没正常启动;
B) 检查网线有没有插紧,或者换根网线试下;
C) 换个路由器试下(路由器的问题有遇到过很多,比如路由器无法正常分配IP 地址,或者已正常分配 IP 地址但在路由器中看不到);
D) 如果没有路由器可换就只能连接 HDMI 显示器或者使用调试串口来查看 IP地址。

另外需要注意的是开发板 DHCP 自动分配 IP 地址是不需要任何设置的。

4) 测试网络连通性的命令如下,ping 命令可以通过 Ctrl+C 快捷键来中断运行

orangepi@orangepi:~$ ping www.baidu.com -I eth0

PING www.a.shifen.com (14.215.177.38) from 192.168.1.12 eth0: 56(84) bytes of data.
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=1 ttl=56 time=6.74 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=2 ttl=56 time=6.80 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=3 ttl=56 time=6.26 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=4 ttl=56 time=7.27 ms
^C
--- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 6.260/6.770/7.275/0.373 ms