一 更改国内源
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