ubuntu18.04网络配置
ubuntu18.04主机名修改
主机名修改,重启生效
# 查询系统信息
uname -a
lsb_release -a
# 修改主机名,重启生效
cat /etc/cloud/cloud.cfg | grep "preserve_hostname"
sudo cp /etc/cloud/cloud.cfg /etc/cloud/cloud.cfg.backup
sudo sed -i "s|preserve_hostname.*|preserve_hostname: true|g" /etc/cloud/cloud.cfg
sudo hostnamectl set-hostname ubuntu
sudo reboot
ubuntu18.04网络配置
动态网络配置,配置文件/etc/netplan/50-cloud-init.yaml
sudo cp /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.backup
sudo vim /etc/netplan/50-cloud-init.yaml
network:
renderer: networkd
ethernets:
ens33:
dhcp4: yes
dhcp6: yes
version: 2
# 应用网络计划
sudo netplan apply
静态网络配置,配置文件/etc/netplan/50-cloud-init.yaml
sudo cp /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.backup
sudo vim /etc/netplan/50-cloud-init.yaml
network:
renderer: networkd
ethernets:
ens33:
dhcp4: no
addresses: [192.168.0.151/24]
gateway4: 192.168.0.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
search: []
optional: true
version: 2
# 应用网络计划
sudo netplan apply
配置多张网卡,配置文件/etc/netplan/50-cloud-init.yaml
sudo cp /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.backup
sudo vim /etc/netplan/50-cloud-init.yaml
network:
renderer: networkd
ethernets:
ens33:
dhcp4: yes
dhcp6: no
ens34:
dhcp4: no
dhcp6: no
addresses: [192.168.0.151/24]
gateway4: 192.168.0.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
search: []
optional: true
version: 2
# 应用网络计划
sudo netplan apply
ubuntu18.04配置中科大源
/etc/apt/sources.list
最前面追加如下内容
vim /etc/apt/sources.list
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
sudo apt-get update
sudo apt-get upgrade