Ubuntu 22.04 版本默认使用的网络配置命令是 ip 而不是 ifconfig 和 net-tools。ifconfig 和 net-tools 包可能已被废弃,不再被默认安装。
解决方法:
- 安装
net-tools 以使用 ifconfig 和 netstat 等传统工具:
sudo apt update
sudo apt install net-tools
- 使用
ip 命令代替 ifconfig 的功能:
ip addr show
sudo ip link set eth0 up
sudo ip link set eth0 down
sudo ip addr add 192.168.1.10/24 dev eth0
sudo ip addr del 192.168.1.10/24 dev eth0
- 如果你需要使用 DHCP 获取动态 IP,可以使用:
sudo ip addr add dev eth0 scope global dynamic
- 查看路由信息:
ip route show
- 添加一个默认网关:
sudo ip route add default via 192.168.1.1
- 删除一个路由:
sudo ip route del default via 192.168.1.1
以上步骤应该能帮助你解决在Ubuntu 22.04 上遇到的网络配置问题。