ubuntu下配置静态IP

来源:互联网 发布:java手机游戏下载 编辑:程序博客网 时间:2024/05/16 05:19

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 interfaceauto loiface lo inet loopback# The primary network interfaceauto eth0iface eth0 inet static   # 把dhcp改成staticaddress 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.35nameserver 202.101.172.47

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

sudo ifdown eth0sudo ifup eth0# 或sudo /etc/init.d/network restart
0 0
原创粉丝点击