root@doupai-KVM:~# cat /etc/network/interfaces # interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback auto ens3 iface ens3 inet static address 192.168.200.7 netmask 255.255.255.0 gateway 192.168.200.1 dns-nameserver 192.168.200.200
ubuntu18.04.2修改IP地址的方法有所變更,Ubuntu 18.04 採用netplan做爲網絡配置管理,與16.04及以前的版本區別很大。ubuntu
root@doupai:~# cat /etc/netplan/50-cloud-init.yaml network: ethernets: ens3: addresses: - 192.168.200.136/24 gateway4: 192.168.200.1 nameservers: addresses: - 192.168.200.200 version: 2
修改完以後,重啓網絡便可。vim
root@doupai:~# /etc/init.d/networking restart [ ok ] Restarting networking (via systemctl): networking.service.
將舊版本內容作好備份。網絡
root@doupai-KVM:~# cp /etc/apt/sources.list /etc/apt/sources.list_bak
添加如下內容ssh
root@doupai-KVM:~# cat /etc/apt/sources.list deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial universe deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties deb http://archive.canonical.com/ubuntu xenial partner deb-src http://archive.canonical.com/ubuntu xenial partner deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
更新本身的源,便可ide
root@doupai-KVM:~# apt update root@doupai-KVM:~# apt-get update
接下來驗證源是否正常使用:oop
root@doupai-KVM:~# apt install -y openssh-server vim net-tools lrzsz