歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 關於 Ubuntu 設置靜態IP的問題

關於 Ubuntu 設置靜態IP的問題

日期:2017/2/28 15:51:36   编辑:Linux教程

之前我安裝也過Ubuntu server ,因為ubuntu server 沒有圖形界面,配置靜態ip就必須使用vi編輯器來編輯/etc/network/interfaces文件實現,但是就是設置不成功,不知道是什麼原因,網上的資料也查詢了,都是一個設置方式。

通過不斷的實驗,終於配置成功,留下日志備查:

使用vi,輸入命令(為了不輸入sudo 我直接切換到root賬戶):

sudo su
vi /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 interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
# iface eth0 inet dhcp
iface eth0 inet static
address 192.168.0.6
netmask 255.255.255.0
gateway 192.168.0.1

注意對比,配置完成之後,重啟網絡:

/etc/init.d/networking restart
如果不是root賬戶,記得加sudo哦

昨天設置了靜態IP,今天再打開電腦的時候卻發現服務器不能聯網了,奇怪,後來想了想是不是我沒有設置DNS的緣故,使用vi編輯器打開/etc/resolv.conf:

vi /etc/resolv.conf
添加DNS:

search mydomain.com
nameserver 61.139.39.73
nameserver 61.139.2.69

配置完成之後,重啟網絡:

/etc/init.d/networking restart
問題解決!

更多Ubuntu相關信息見Ubuntu 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=2

Copyright © Linux教程網 All Rights Reserved