Ubuntu設置固定IP

給192.168.1.244設定爲固定Ipvim

1.找到文件並做以下修改:服務器

vim /etc/network/interfacesoop

修改結果爲以下部分:spa

# This file describes the network interfaces available on your systemrest

# and how to activate them. For more information, see interfaces(5).orm

# The loopback network interfaceserver

auto lodns

iface lo inet loopbackip

# The primary network interfaceit

auto p2p1

iface p2p1 inet static

address 192.168.1.244

gateway 192.168.1.1

netmask 255.255.255.0

注:p2p1爲192.168.1.244網卡名,不一樣服務器網卡名不一樣,請自行修改

 

2. 修改dns解析

由於之前是dhcp解析,因此會自動分配dns服務器地址

而一旦設置爲靜態ip後就沒有自動獲取到的dns服務器了

要本身設置一個

vim /etc/resolv.conf

nameserver 202.96.128.86

nameserver 192.168.1.1

nameserver 220.170.64.68

3.改完上面,若是重啓的話,仍是會變爲原來的樣子,因此要讓其永久改變,所以,執行:

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

   nameserver 192.168.1.1

   nameserver 220.170.64.68

3. 重啓網卡:

/etc/init.d/networking restart

相關文章
相關標籤/搜索