赞
踩
注: 以下操作均基于VMWARE虚拟环境,需要确认虚拟网络配置为NAT模式。
检查方式:编辑——>虚拟网络编辑器,进入到以下页面。配置和记住当前设置的网关IP、子网掩码、IP段
开启虚拟机,进入到terminal,切换到管理员模式:
# 执行后输入登录用户密码
sudo -i
# 初装系统root密码为随机密码,需要自行更改
passwd root
# 按照提示之后输入命令更改密码,提示successful为更新成功
# 之后登录执行以下指令直接进入管理员模式
su
Ubuntu自17.10版本以来,引入了Netplan网络配置工具,通过netplan进行管理,对应的配置文件如下:
# 新安装的系统建议使用vi或nano编辑器修改文件内容,不支持vim
vi /etc/netplan/01-network-manager-all.yaml
nano /etc/netplan/01-network-manager-all.yaml
配置内容:
# Let NetworkManager manage all devices on this system network: ethernets: ens33: dhcp4: no dhcp6: no # 该项可选,不加也可行 optional: true addresses: # 静态IP,需要在第一节配置的IP段内 - 192.168.31.103/24 routes: - to: default # 网关设置,需要和第一节检查的网关一致 via: 192.168.31.2 nameservers: # 网关配置格式还可采用该格式,多个地址采用英文逗号相隔 # addresses: [114.114.114.114,8.8.8.8] addresses: - 114.114.114.114 - 8.8.8.8 search: - localhost - local version: 2 renderer: NetworkManager
# 测试配置;正常如下
sudo netplan try
# 应用配置:不报错即可
sudo netplan apply
检查是否生效:
ip addr
连通性检查:
ping www.baidu.com
在系统使用过程中有一些工具为常用工具,建议安装,如vim、net-tools(对应ifconfig指令)、curl。该部分内容自行参考安装。
# vim编辑器,vi的升级版
apt install vim -y
# ifconfig、netstat命令工具
apt install net-tools -y
# web服务器请求工具
apt install curl -y
# 执行以下指令一键安装
apt install vim -y;apt install net-tools -y;apt install curl -y
注: 不同系统版本设定的源不同,以下针对22.04版本。
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-backports main restricted universe multiverse
将原来的源文件进行备份:
mv /etc/apt/sources.list /etc/apt/sources.list.bak
新建源文件:
# 填入上一节的任意一项可用源,之后执行Esc : 输入wq保存退出
vi /etc/apt/sources.list
更新软件源:
apt update -y
至此,配置完成,以上为个人经验总结和分享,如有错误欢迎指正,觉得有用的小伙伴可以点个赞或收藏鼓励一下哟~
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。