debian配置靜態IP

  最近有個困擾,虛擬機下的Debian系統在更換網絡環境後ip地址會發生變化,從而影響到個人nfs服務器和Navicat訪問數據庫,如下是解決方法數據庫

 

首先編輯/etc/network/interfaces設置IP地址和網關,最好先備份,若是你要配置的是eth0網卡,設置以下服務器

auto lo網絡

iface lo inet loopbackoop

 

# The primary network interfacespa

auto eth0 #設置開機自動鏈接網絡rest

allow-hotplug eth0server

iface eth0 inet static #static表示固定ip , dhcp表示使用動態ipdns

address 192.168.199.xxx #設置ip地址ip

netmask http://www.javashuo.com/tag/255.255.255.0 #設置子網掩碼get

network 192.168.199.0 #

broadcast 192.168.199.255

gateway 192.168.199.1 #設置網關

 

其次編輯/etc/resolv.conf配置dns,設置以下

 

nameserver 192.168.199.1 # 通常和gateway的地址是一致的

 

最後重啓網絡

 

service networking restart #重啓網絡

或者

/etc/init.d/networking restart #記得sudo

相關文章
相關標籤/搜索