先查看本机当前的IP地址,命令
ip address
信息如下:enp2s0是网卡名字,这个记住,后面要用到,下面的inet 192.168.3.139/24就是本机当前的ip地址,这个是路由器随机分配的。
并且关闭DHCP
输入:nano /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
allow-hotplug enp2s0
# iface enp2s0 inet dhcp
auto enp2s0
iface enp2s0 inet static
address 192.168.1.3
netmask 255.255.255.0
gateway 192.168.1.1
reboot重启却可