sudo vi /etc/netplan/00-installer-config.yaml
network:
version: 2
ethernets:
ens32:
dhcp4: false
addresses: [192.168.1.5/24]
gateway4: 192.168.1.1
nameservers:
addresses: [114.114.114.114]
#addresses: 192.168.1.5/24] #设置的IP地址和子网掩码
#gateway4: 192.168.1.1#网关
#nameservers: #可以理解为DNS(名字解析服务)
#addresses: [114.114.114.114] #DNS1,DNS2
#更新ip
sudo netplan apply
#修改主机名
sudo hostnamectl set-hostname k8s-mast
#hosts文件 域名通信
echo 192.168.1.20 k8s-mast >> /etc/hosts
#更新阿里云yum
sudo vim /etc/apt/sources.list
#添加阿里源
deb http://mirrors.aliyun.com/ubuntu focal main restricted
deb-src http://mirrors.aliyun.com/ubuntu focal main restricted
deb http://mirrors.aliyun.com/ubuntu focal-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu focal-updates main restricted
deb http://mirrors.aliyun.com/ubuntu focal universe
deb-src http://mirrors.aliyun.com/ubuntu focal universe
deb http://mirrors.aliyun.com/ubuntu focal-updates universe
deb-src http://mirrors.aliyun.com/ubuntu focal-updates universe
deb http://mirrors.aliyun.com/ubuntu focal multiverse
deb-src http://mirrors.aliyun.com/ubuntu focal multiverse
deb http://mirrors.aliyun.com/ubuntu focal-updates multiverse
deb-src http://mirrors.aliyun.com/ubuntu focal-updates multiverse
deb http://mirrors.aliyun.com/ubuntu focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu focal-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu focal-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu focal-security main restricted
deb http://mirrors.aliyun.com/ubuntu focal-security universe
deb-src http://mirrors.aliyun.com/ubuntu focal-security universe
deb http://mirrors.aliyun.com/ubuntu focal-security multiverse
deb-src http://mirrors.aliyun.com/ubuntu focal-security multiverse
deb https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main
##更新源
sudo apt-get update
##更新软件
sudo apt-get -f install
sudo apt-get update
sudo apt-get install ntpdate -y
sudo apt-get upgrade -y
sudo timedatectl set-timezone Asia/Shanghai
sudo ntpdate time.windows.com
#安装ssh
sudo apt-get install openssh-server openssh-client net-tools
#启动ssh
sudo /etc/init.d/ssh restart
#关闭防火墙
sudo systemctl stop ufw.service && sudo systemctl disable ufw.service