由于Ubuntu重启之后,ip很容易改变,可以用以下方式固定ip地址

1.设置ip地址

vi /etc/network/interface

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto enp0s3
iface enp0s3 inet static
address 192.168.117.50
netmask 255.255.255.0
gateway 192.168.117.1

enp0s3
2.设置dns

vi /etc/resolvconf/resolv.conf.d/base
nameserver 8.8.8.8
nameserver 8.8.4.4

3.刷新配置文件

resolvconf -u

4.重启网络服务

/etc/init.d/networking restart

如果上述命令重启网卡失败,可以手动关闭网卡,再打开网卡,这是ip已经改过来了,变成你设置的固定的ip了

 

相关文章:

  • 2022-12-23
  • 2021-11-29
  • 2021-11-19
  • 2022-01-05
  • 2022-01-07
  • 2021-09-24
  • 2021-05-22
猜你喜欢
  • 2021-04-03
  • 2021-08-06
  • 2022-12-23
  • 2021-08-08
  • 2022-01-08
  • 2021-12-04
相关资源
相似解决方案