进入root用户

如何切换root用户请看 https://foxwho.blog.csdn.net/article/details/125423062

安装必备软件

apt install vim curl wget -y

ubuntu 22 查看ip配置

进入 /etc/netplan/ 查看 ip配置文件,00-installer-config.yaml 这个文件是我这的ip配置文件,每个版本的可能定义不一样

cat /etc/netplan/00-installer-config.yaml

输出

# This is the network config written by 'subiquity'
network:
  ethernets:
    eth0:
      dhcp4: true
  version: 2

ubuntu 22 设置静态ip

vim /etc/netplan/00-installer-config.yaml

内容修改如下

network:
  ethernets:
    eth0:
      dhcp4: false
      dhcp6: false
      addresses: 
        - 192.168.10.120/24
      optional: true
      routes:
        - to: default
          via: 192.168.10.1
      set-name: eth0
      nameservers:
        addresses: 
          - 223.5.5.5
          - 223.6.6.6
        search:
          - localhost
          - local
  version: 2

应用并生效

netplan apply 
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐