本文主要是介绍ROS 配置多网口通讯,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
列出当前所有的网络设备
ifconfig -a
结果如下:
enp1s0 Link encap:Ethernet HWaddr 00:2f:5c:68:06:ad inet addr:192.168.1.101 Bcast:192.168.1.255 Mask:255.255.255.0inet6 addr: fdf7:383f:9b8:0:22f:5cff:fe68:6ad/64 Scope:Globalinet6 addr: fe80::22f:5cff:fe68:6ad/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:304564 errors:0 dropped:0 overruns:0 frame:0TX packets:534178 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000 RX bytes:20678086 (20.6 MB) TX bytes:517202711 (517.2 MB)enp2s0 Link encap:Ethernet HWaddr 00:2f:5c:68:06:ae inet addr:192.168.0.20 Bcast:192.168.0.255 Mask:255.255.255.0inet6 addr: fe80::22f:5cff:fe68:6ae/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:737867 errors:0 dropped:0 overruns:0 frame:0TX packets:368418 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000 RX bytes:821034912 (821.0 MB) TX bytes:22109842 (22.1 MB)lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0inet6 addr: ::1/128 Scope:HostUP LOOPBACK RUNNING MTU:65536 Metric:1RX packets:7389607 errors:0 dropped:0 overruns:0 frame:0TX packets:7389607 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1 RX bytes:175956695855 (175.9 GB) TX bytes:175956695855 (175.9 GB)wlp3s0 Link encap:Ethernet HWaddr 4c:ed:de:f5:af:4f UP BROADCAST MULTICAST MTU:1500 Metric:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:0 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
更改网络配置:
sudo vim /etc/network/interfaces
内容如下:(注意:网卡名称以及是否是单双网卡)
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).source /etc/network/interfaces.d/*# The loopback network interface
auto lo
iface lo inet loopback# The primary network interface
#iauto enp1s0
#iface enp1s0 inet dhcpauto enp1s0
iface enp1s0 inet static
address 192.168.1.101
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 211.138.24.66 211.138.30.66#----hokuyo laser-------#
#auto enp2s0
#iface enp2s0 inet static
#address 192.168.0.20#----pavo laser-------#
auto enp2s0
iface enp2s0 inet static
address 10.10.10.100
这篇关于ROS 配置多网口通讯的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!