Ubuntu更改国内源,设置固定IP和DNS

一 更改国内源ubuntu

 

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)。如图所示:spa

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

 

二 设置固定IPrest

 1 编辑 /etc/network/interfacescode

$ sudo nano /etc/network/interfaces

 

2 注释掉 iface eth0 inet dhcp这一行并添加以下内容,以设置为固定IP 192.168.1.85为例server

iface eth0 inet static
address 192.168.1.85
netmask 255.255.255.0
gateway 192.168.1.1

 

3 重启eth0,不是root的加sudoblog

$ ifconfig eth0 down
$ ifconfig eth0 up

 

4 重启网卡dns

$ /etc/init.d/networking restart

 

三 设置静态dns服务器it

 

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
相关文章
相关标签/搜索