当前位置: 代码迷 >> 综合 >> 在Ubuntu Linux中设置静态IP
  详细解决方案

在Ubuntu Linux中设置静态IP

热度:69   发布时间:2024-01-16 12:56:50.0

Ubuntu的网络配置信息是保存在 /etc/network/interfaces 文件中,使用Vim打开配置文件,默认是自动获取IP的配置.如下:
# The primary network interface
auto eth0
iface eth0 inet dhcp
下面我们将其设置成静态IP.
第一步:屏蔽掉自动获取IP的设置
iface eth0 inet dhcp将这一行屏蔽掉
修改之后的内容如下:
# The primary network interface
auto eth0
#iface eth0 inet dhcp
第二步:添加静态IP的信息
# The primary network interface
iface eth0 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1
第三步:设置DNS
编辑 /etc/resolv.conf,设置dns
nameserver 202.96.134.133
nameserver 202.106.0.20
重启网络:/etc/init.d/networking restart
以上步骤完成之后只要重新启用一下网络就OK了.