一、查看系统版本
使用 lsb_release -a 命令可以查看系统版本,
root@ubuntu:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04 LTS
Release: 24.04
Codename: noble
或者直接查看 /etc/lsb-release 文件
root@ubuntu:~# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=24.04
DISTRIB_CODENAME=noble
DISTRIB_DESCRIPTION="Ubuntu 24.04 LTS"
二、配置网络
使用 ip 命令来查看网卡接口。
root@ubuntu:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:a0:8e:df brd ff:ff:ff:ff:ff:ff
altname enp2s0
inet 192.168.31.128/24 metric 100 brd 192.168.31.255 scope global dynamic ens32
valid_lft 1298sec preferred_lft 1298sec
inet6 fe80::20c:29ff:fea0:8edf/64 scope link
valid_lft forever preferred_lft forever
编辑文件 /etc/netplan/99_config.yaml (没有的话先新建),如果使用 dhcp 来自动获取 IP 可以可以配置
network:
version: 2
renderer: networkd
ethernets:
ens32:
dhcp4: true
想要配置固定IP地址,如下配置
network:
version: 2
renderer: networkd
ethernets:
ens32:
addresses: [192.168.31.128/24]
routes:
- to: default
via: 192.168.31.2
nameservers:
addresses: [114.114.114.114, 8.8.8.8]
然后应用配置即可
netplan apply
张贴您的评论