[RK3288][Android6.0] 调试笔记 --- 外网和内网同时使用
程序员文章站
2022-06-01 13:28:17
...
PC:Ubuntu 14.04 LTS
需求:
同时接了两个网段,一个内网,一个外网。
由于对网络不熟悉,之前都是同时只用一个网段,不方便。
今天同事帮我解决了这个问题,感谢他!
方法:
1. 查看当前以太网和无线ip
kris@eco:~$ ifconfig -a
eth0 Link encap:Ethernet HWaddr b0:83:fe:76:8a:89
inet addr:10.89.14.40 Bcast:10.89.14.255 Mask:255.255.255.0
inet6 addr: fe80::b283:feff:fe76:8a89/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:861106 errors:0 dropped:0 overruns:0 frame:0
TX packets:1022785 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:97838573 (97.8 MB) TX bytes:117304452 (117.3 MB)
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:1870073 errors:0 dropped:0 overruns:0 frame:0
TX packets:1870073 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:438431142 (438.4 MB) TX bytes:438431142 (438.4 MB)
wlan0 Link encap:Ethernet HWaddr 44:33:4c:34:6c:f1
inet addr:172.20.10.6 Bcast:172.20.10.15 Mask:255.255.255.240
inet6 addr: fe80::4633:4cff:fe34:6cf1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:41022 errors:0 dropped:98079 overruns:0 frame:0
TX packets:41126 errors:0 dropped:22 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:980856086 (980.8 MB) TX bytes:200548455 (200.5 MB)
2. 添加路由
[email protected]:~$ sudo route add default gw 172.20.10.1
3.查看当前路由,已经有两个了
kris@eco:~$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.20.10.1 0.0.0.0 UG 0 0 0 wlan0
0.0.0.0 10.89.14.254 0.0.0.0 UG 0 0 0 eth0
10.89.14.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0
10.89.18.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
172.20.10.0 0.0.0.0 255.255.255.240 U 9 0 0 wlan0
4.把要访问的内网网段添加到以太网路由规则中。
[email protected]:~$ route add -net 10.89.18.0 netmask 255.255.255.0 dev eth0
这样就可以了,不过重启之后就会没有,可以写在脚本里。