1.前言:
作者是在做机器人时遇到这个问题的,我的雷达是利用有线网口通讯的,设备地址是192.168.11.1,而我连上雷达后就不能通过其他网卡进行上网了。所以我想做到利用wifi上互联网并且利用网线和雷达通讯。
2.实现原理:
利用对网络的配置文件将你的内网设置为静态网络(既是不连接互联网)来实现。
3.实现方法:
打开终端:
1.查询IP地址和网络信息:
ifconfig
也可以用 这个:
route
2.找到你要设置为内网的网络注册名字
一般有线是eth或者enp什么的开头,无线是wlp开头
xs@xs:~$ ifconfig
enp4s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 0c:9d:92:a4:ef:4d txqueuelen 1000 (以太网)
RX packets 1932 bytes 1720331 (1.7 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1989 bytes 224222 (224.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (本地环回)
RX packets 15109 bytes 2574967 (2.5 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 15109 bytes 2574967 (2.5 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.9.156 netmask 255.255.255.0 broadcast 192.168.9.255
inet6 fe80::ff9c:7678:6a56:e60c prefixlen 64 scopeid 0x20<link>
inet6 240e:46c:8c02:1802:b162:b2b1:67c6:5f07 prefixlen 64 scopeid 0x0<global>
inet6 240e:46c:8c02:1802:93dd:40dd:677a:4f42 prefixlen 64 scopeid 0x0<global>
ether d0:c5:d3:71:9a:29 txqueuelen 1000 (以太网)
RX packets 30021 bytes 76553357 (76.5 MB)
RX errors 0 dropped 78 overruns 0 frame 0
TX packets 17856 bytes 5517337 (5.5 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
我这里有线名字就是enp4s0。
3.打开并修改interfaces文件
sudo vi /etc/network/interfaces
#interfaces(5) file used by ifup(8) and ifdown(8)auto lo
iface lo inet loopback
#The primary network interface
auto enp4s0
iface enp4s0. inet static
address 192.168.11.200
netmask 255.255.255.0
dns - nameserver 119.29.29.29
注意没有为enp4s0(内部网络) 设置gateway.如果有的话就得把它删除。
4.保存文件 wq 后 重启电脑就可以了。
4.参考链接:
https://www.qieseo.com/139105.htmlhttps://www.qieseo.com/139105.html