ubuntu16 配置静态ip(NAT方式)

来源:互联网 发布:sql 年月日变成日期 编辑:程序博客网 时间:2024/05/29 07:27

第一步 输入命令 ip addr ,查看我们的ip地址,默认为dhcp分配的地址;

第二步 输入命令 ifconfig 查看网卡名称 (常见的有eth0,ens33

第三步 sudo vi  /etc/network/interface 

添加如下命令

auto 网卡名称 

iface 网卡名称  inet static
address 192.168.8.100    
netmask 255.255.255.0
gateway 192.168.8.2
dns-nameserver 119.29.29.29


第四步

重启网络:sudo /etc/init.d/networking restart


第五步 

ping www.baidu.com  


成功!

0 0
原创粉丝点击