ubuntu下配置静态IP

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wl812peter/article/details/60867201

ubuntu下配置静态IP

先执行如下命令:

sudo 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).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static   # 把dhcp改成static
address 192.168.10.211   # 固定本机的IP地址
gateway 192.168.10.1     # 检查当前网络的网关,填入这里
netmask 255.255.255.0    # 子网掩码
# 配置DNS解析,根据自己网络的运营商以及地址去百度上搜吧,本人这里是杭州电信
dns-nameserves 202.101.172.35 202.101.172.47

DNS解析也可通过如下设置:

sudo vim /etc/resolv.conf

修改如下:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 配置DNS解析,操作同上,这里是杭州电信
nameserver 202.101.172.35
nameserver 202.101.172.47

上述操作完成后,重启网络,输入如下命令:

sudo ifdown eth0
sudo ifup eth0
# 或
sudo /etc/init.d/network restart
展开阅读全文

没有更多推荐了,返回首页