root@temple-102:~# ifconfig
eno1 Link encap:Ethernet HWaddr 0c:c4:7a:e6:49:74
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)
Memory:fb220000-fb23ffff
eno2 Link encap:Ethernet HWaddr 0c:c4:7a:e6:49:75
inet addr:192.168.1.102 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::ec4:7aff:fee6:4975/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:131 errors:0 dropped:0 overruns:0 frame:0
TX packets:99 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11603 (11.6 KB) TX bytes:13765 (13.7 KB)
Memory:fb200000-fb21ffff
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:170 errors:0 dropped:0 overruns:0 frame:0
TX packets:170 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:12488 (12.4 KB) TX bytes:12488 (12.4 KB)
记住网卡名字 eno2(根据实际情况不一致)
root@temple-102:~# cat /etc/network/interfaces # interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback auto eno2 iface eno2 inet static address 192.168.1.102 netmask 255.255.255.0 gateway 192.168.1.1 dns-nameserver 8.8.8.8
root@temple-102:~# /etc/init.d/networking restart [ ok ] Restarting networking (via systemctl): networking.service.
可能会不生效, 重启电脑生效!