觀察一下 Raspberry Pi 上面有那些可以用的網卡 可以用最常見的指令 ifconfig
root@raspberrypi:~ # ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:eb:09:91:ed
inet addr:192.168.xx.xx Bcast:192.168.xx.255 Mask:255.255.255.0
inet6 addr: fe80::4aec:c77b:6146:1e0c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3562 errors:0 dropped:0 overruns:0 frame:0
TX packets:1437 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1934821 (1.8 MiB) TX bytes:192249 (187.7 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:282 errors:0 dropped:0 overruns:0 frame:0
TX packets:282 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:22992 (22.4 KiB) TX bytes:22992 (22.4 KiB)
或是用Uinx家族都有的指令 ip addr
root@raspberrypi:~ # ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:09:91:ed brd ff:ff:ff:ff:ff:ff
inet 192.168.xx.xx/24 brd 192.168.xx.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::4aec:c77b:6146:1e0c/64 scope link
valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether b8:27:eb:5c:c4:b8 brd ff:ff:ff:ff:ff:ff
inet6 fe80::1959:afa7:6e4e:85fe/64 scope link tentative
valid_lft forever preferred_lft forever
由上面的指令可以得到目前有 eth0 和 wlan0 可以用, eth0 為有線網路, 如果您的網路有dhcp應該就可以自動連線了
當看到有IP資訊, 網卡也正常工作, 那就使用 ping 來測試一下連線了, 我們測試的目標是Google的伺服器IP是8.8.8.8
root@raspberrypi:~ # ping 8.8.8.8 -c 4
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=44 time=11.2 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=44 time=10.6 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=44 time=13.8 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=44 time=12.8 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=44 time=11.8 ms
--- 8.8.8.8 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 10.668/12.089/13.874/1.160 ms