Ubuntu更改國內源,設置固定IP和DNS


一 更改國內源

 

1 首先備份官方源,以免設置錯誤可恢復。

$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.back

 

2 用編輯器打開 /etc/apt/sources.list文件。

$ sudo nano /etc/apt/sources.list

 

3 刪除原有的源,在編輯器中添加新源(阿里源,14.04)。如圖所示:

deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

 

二 設置固定IP

 1 編輯 /etc/network/interfaces

$ sudo nano /etc/network/interfaces

 

2 注釋掉 iface eth0 inet dhcp這一行並添加如下內容,以設置為固定IP 192.168.1.85為例

iface eth0 inet static
address 192.168.1.85
netmask 255.255.255.0
gateway 192.168.1.1

 

3 重啟eth0,不是root的加sudo

$ ifconfig eth0 down
$ ifconfig eth0 up

 

4 重啟網卡

$ /etc/init.d/networking restart

 

三 設置靜態dns服務器

 

1 增加文件

$ sudo nano /etc/resolvconf/resolv.conf.d/tail

 

2 增加nameserver,如下:

nameserver 202.102.134.68
nameserver 8.8.8.8

 

3 重啟dns解析

$ sudo /etc/init.d/resolvconf restart

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM