ubuntu server設置靜態IP和DNS

設置IP:

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表示使用固定ipdhcp表述使用動態ip
address 是本機IP地址
netmask 子網掩碼
gateway 網關spa

若是使用nano編輯的話
ctrl+o  #保存配置
ctrl+x  #退出rest

設置DNS

linux系統的DNS信息是保存在/etc/resolv.conf , 可是在ubuntu中用vim打開這個文件你會發現有以下文字的提示code

DO NOT EDIT THIS FILE BY HAND — YOUR CHANGES WILL BE OVERWRITTENorm

因此不能直接個性這個文件,這個內容可能會被覆蓋server

在ubuntu中dns信息是放在/etc/resolvconf/resolv.conf.d/目錄下

通常狀況下這個目錄下有base和head兩個文件夾

vim /etc/resolvconf/resolv.conf.d/base

nameserver 8.8.8.8
nameserver 114.114.114.114

保存後執行

resolvconf -u

用如下命令使網絡設置生效

service networking restart
sudo /etc/init.d/networking restart

相關文章
相關標籤/搜索