列出当前所有的网络设备
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.0
inet6 addr: fdf7:383f:9b8:0:22f:5cff:fe68:6ad/64 Scope:Global
inet6 addr: fe80::22f:5cff:fe68:6ad/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:304564 errors:0 dropped:0 overruns:0 frame:0
TX packets:534178 errors:0 dropped:0 overruns:0 carrier:0
collisions: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.0
inet6 addr: fe80::22f:5cff:fe68:6ae/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:737867 errors:0 dropped:0 overruns:0 frame:0
TX packets:368418 errors:0 dropped:0 overruns:0 carrier:0
collisions: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.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:7389607 errors:0 dropped:0 overruns:0 frame:0
TX packets:7389607 errors:0 dropped:0 overruns:0 carrier:0
collisions: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:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions: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 dhcp
auto 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