admin管理员组

文章数量:1631138

继续上一篇,ubuntu mate系统使用4G模块

同样的是模块接入到树莓派上之后系统自动识别,可以在lsusb和ifconfig查看到设备和usb0

网卡。

直接在右上角的network-manager中添加移动宽带,默认信息不用修改,直接下一步,密码随意填写,设置网络为自动连接。


此时usb0应该已经联网并分配到IP地址,可以通过ifconfig查看:
pi@pi-desktop:~$ ifconfig
enxb827ebdc8c6f Link encap:Ethernet  HWaddr b8:27:eb:dc:8c:6f  
          inet addr:192.168.1.101  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::ca29:cc82:f9d1:dd9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:16201 errors:0 dropped:0 overruns:0 frame:0
          TX packets:731 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:902950 (902.9 KB)  TX bytes:65708 (65.7 KB)
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:440 errors:0 dropped:0 overruns:0 frame:0
          TX packets:440 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:30283 (30.2 KB)  TX bytes:30283 (30.2 KB)
usb0      Link encap:Ethernet  HWaddr 02:1e:10:1f:00:00  
          inet addr:172.24.119.177  Bcast:172.24.119.179  Mask:255.255.255.252
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14 errors:0 dropped:0 overruns:0 frame:0
          TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1982 (1.9 KB)  TX bytes:4629 (4.6 KB)
wlan0     Link encap:Ethernet  HWaddr b8:27:eb:89:d9:3a  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:242 errors:0 dropped:242 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 

          RX bytes:85717 (85.7 KB)  TX bytes:0 (0.0 B)

同上一篇一样,需要修改路由表来实现内外网同时使用两块网卡,如下:

route –n查看:
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 enxb827ebdc8c6f
0.0.0.0         10.27.145.49    0.0.0.0         UG    700    0        0 usb0
10.27.145.48    0.0.0.0         255.255.255.248 U     700    0        0 usb0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 enxb827ebdc8c6f
192.168.1.0     0.0.0.0         255.255.255.0   U     100    0        0 enxb827ebdc8c6f


此时并不能访问外网,因为默认的目标是通过内网的以太网卡来访问,所以我们把这条路由信息删除:


sudo route del -net 0.0.0.0 enxb827ebdc8c6f


再查看路由表:
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.27.145.49    0.0.0.0         UG    700    0        0 usb0
10.27.145.48    0.0.0.0         255.255.255.248 U     700    0        0 usb0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 enxb827ebdc8c6f
192.168.1.0     0.0.0.0         255.255.255.0   U     100    0        0 enxb827ebdc8c6f


此时可以顺利访问内外网,内网使用有线连接的以太网卡,外网使用的4G模块:
pi@pi-desktop:~$ ping www.baidu
PING www.a.shifen (61.135.169.125) 56(84) bytes of data.
64 bytes from 61.135.169.125: icmp_seq=1 ttl=53 time=26.1 ms
64 bytes from 61.135.169.125: icmp_seq=2 ttl=53 time=39.2 ms

pi@pi-desktop:~$ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.311 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.294 ms

本文标签: 华为模块方法树莓派ME909s