vim /etc/network/interfaceshtml
將如下內容:linux
auto eth0
iface eth0 inet dhcpubuntu
修改成:vim
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx網絡
把xxx.xxx.xxx設置爲你要個性的信息既可,其中auto eth0
#開機自動鏈接網絡iface eth0 inet static
#static
表示使用固定ip,dhcp
表述使用動態ipaddress
是本機IP地址netmask
子網掩碼gateway
網關spa
若是使用nano
編輯的話
ctrl+o #保存配置
ctrl+x #退出rest
linux系統的DNS信息是保存在/etc/resolv.conf , 可是在ubuntu中用vim打開這個文件你會發現有以下文字的提示code
DO NOT EDIT THIS FILE BY HAND — YOUR CHANGES WILL BE OVERWRITTEN
orm
因此不能直接個性這個文件,這個內容可能會被覆蓋server
在ubuntu中dns信息是放在/etc/resolvconf/resolv.conf.d/目錄下
通常狀況下這個目錄下有base和head兩個文件夾
vim /etc/resolvconf/resolv.conf.d/base
保存後執行
resolvconf -u
用如下命令使網絡設置生效
service networking restart
sudo /etc/init.d/networking restart
轉載請註明: 飄雲