Ubuntu16.04.7系统如何配置静态IP(其他版本通用)

第一步:找到对应的网卡名称

root@ubuntu:~# ifconfig
root@ubuntu:~# ifconfig
ens33     Link encap:Ethernet  HWaddr 00:0c:29:c8:c1:53
          inet addr:192.168.1.129  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fec8:c153/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:101322 errors:0 dropped:0 overruns:0 frame:0
          TX packets:71624 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:118412908 (118.4 MB)  TX bytes:14883684 (14.8 MB)

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:182 errors:0 dropped:0 overruns:0 frame:0
          TX packets:182 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:13531 (13.5 KB)  TX bytes:13531 (13.5 KB)

root@ubuntu:~#

找到网卡的名称:ens33

 第二步:修改网络配置,可以直接拷贝如下配置

auto ens33                                //网卡
iface ens33 inet static               //设置IP为静态的
address 192.168.1.129             //设置静态的IP地址
netmask 255.255.255.0            //设置子网掩码
gateway 192.168.1.1                //设置网关地址
dns-nameserver 8.8.8.8            //设置DNS解析

root@ubuntu:~# vim /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
auto ens33
iface ens33 inet static
address 192.168.1.129
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameserver 8.8.8.8

~

"/etc/network/interfaces" 17L, 398C   

第三步:重启网络

root@ubuntu:~# sudo /etc/init.d/networking restart

这样我们的Ubuntu系统就有了静态的IP,重启系统后发现IP地址始终是我们设置的静态IP.

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值