目录
1. Ubuntu 笔记
1.1. 配置
1.1.1. 修改静态 IP 地址
Ubuntu 使用新的 Canonical Netplan 来管理网络地址。
步骤 1: 查看当前 IP 地址
在配置静态 IP 地址之前, 需要确定您当前正在使用的 IP 地址。您可以使用 “ip addr” 命令查看当前 IP 地址, 如下所示:
$ ip addr
在输出结果中, 找到您当前正在使用的接口。通常情况下, 该接口名为 “eth0” 或 “enp0s3”。在接口下方, 可以找到当前的 IP 地址和其他网络设置信息。
步骤 2: 备份网络配置文件
在修改网络配置文件之前, 建议先备份当前的配置文件。这样, 如果出现错误, 您可以恢复到先前的配置。
使用以下命令备份网络配置文件:
$ sudo cp /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config.yaml.bak
步骤 3: 编辑网络配置文件
接下来, 您需要编辑网络配置文件。在 Ubuntu 22.04 中, 网络配置文件使用 YAML 格式。使用以下命令编辑配置文件:
$ vi 00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
renderer: networkd
ethernets:
ens33: # 配置的网卡的名称
dhcp4: no # 关闭 DHCP, 如果需要打开 DHCP 则写 yes
addresses:
- 192.168.1.247/24 # 配置的静态 IP 地址和掩码
nameservers:
addresses: [223.5.5.5, 223.6.6.6]
routes:
- to: default
via: 192.168.1.1 # 网关地址。根据网络配置有所不同, 有的是 254
version: 2
在上面的文件中, 我们使用了以下内容:
ens33
: 接口名称。addresses
: 用来设置静态 IP.nameservers
: 用来设置 DNS server.routes
: 用来设置网关。
注意:
- 根据您的环境更改 IP 详细信息和接口名称;
- 在
/etc/netplan
里面的*.yaml
都是生效的。比如,可以再取名为/etc/netplan/01-netcfg.yaml
等。数字越靠后的会覆盖前面的接口配置;
步骤 4: 应用配置更改
应用网络配置更改之前, 您可以使用以下命令检查配置文件是否有语法错误:
$ sudo netplan try
如果配置文件没有语法错误, 则应用更改并重新启动网络服务:
$ sudo netplan
要使上述更改生效, 请使用以下 netplan 命令应用这些更改
$ sudo netplan apply
步骤 5: 验证静态 IP 地址
配置完成后, 您可以使用以下命令验证静态 IP 地址是否生效:
$ ip addr
执行以下命令, 查看接口的 IP 地址
$ ip addr show ens33
执行以下命令, 查看缺省路由
$ ip route show
1.2. 问题
1.2.1. 旧更新源
Ubuntu 官方有一个源 http://old-releases.ubuntu.com/ubuntu
是专为已经过了支持期限的版本服务的。将 /etc/apt/sources.list
备份后打开, 将下面内容贴到该文件中:
deb http://old-releases.ubuntu.com/ubuntu jaunty main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu jaunty-security main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu jaunty-updates main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu jaunty-backports main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu jaunty-proposed main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu jaunty main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu jaunty-security main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu jaunty-updates main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu jaunty-backports main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu jaunty-proposed main restricted universe multiverse
保存后执行 update, 然后再重新 install stunnel, 这回一切 OK 了。
1.2.2. perl: warning: Setting locale failed.
Add the following lines to your bashrc or bash_profile file on the host machine:
# Setting for the new UTF-8 terminal support in Lion
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
If you are using Z shell (zsh), edit file zshrc:
# Setting for the new UTF-8 terminal support in Lion
LC_CTYPE=en_US.UTF-8
LC_ALL=en_US.UTF-8