Liunx下配置静态IP(Ubuntu16.04)

说明

工作中我们常常遇到IP的设置,windows下我们可以很好的固定我们配置的IP,同样当我们的服务器或者是虚拟机是liunx操作系统时,我们也需要把它们的IP固定下来,下面我就介绍下如何在Liunx下去配置静态IP

配置过程

Ubuntu 16.01

  1. 打开配置文件
vim /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.8.100    
netmask 255.255.255.0
gateway 192.168.8.2
dns-nameserver 119.29.29.29
  • address:你的IP地址
  • netmask:掩码
  • gateway:网关
  • dns-nameserver:DNS注意:DNS不配置是上不了网的。
  1. 重启网络
sudo /etc/init.d/networking restart
  1. 如果报错请查看网卡名是否正确
ip addr show

在这里插入图片描述

我电脑是ens33,所以我需要把上面的配置文件里网卡名称更换一下(注意:一共两处

auto ens33
iface ens33 inet static
address 192.168.8.100    
netmask 255.255.255.0
gateway 192.168.8.2
dns-nameserver 119.29.29.29
  1. 修改完成后重新启动网络
sudo /etc/init.d/networking restart
  1. 重启计算机,查看IP检验静态IP是否配置成功

猜你喜欢

转载自blog.csdn.net/weixin_43397326/article/details/83116128