ubuntu server 2404使用netplan配置IP地址

 admin   2025-05-21 10:39   32 人阅读  0 条评论

使用命令查看网卡的设备名,可以看到已经获取到dhcp的地址了
user@vm:~$ sudo lshw -C network
[sudo] password for user:
*-network
description: Ethernet interface
product: 82545EM Gigabit Ethernet Controller (Copper)
vendor: Intel Corporation
physical id: 1
bus info: pci@0000:02:01.0
logical name: ens33
version: 01
serial: 00:0c:29:73:aa:83
size: 1Gbit/s
capacity: 1Gbit/s
width: 64 bits
clock: 66MHz
capabilities: pm pcix bus_master cap_list rom ethernet physical logical tp 10bt 10bt-fd 100bt 100bt-f
d 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=e1000 driverversion=6.8.0-60-generic duplex=fu
ll ip=192.168.152.136 latency=0 link=yes mingnt=255 multicast=yes port=twisted pair spee ed=1Gbit/s
resources: irq:19 memory:fd5c0000-fd5dffff memory:fdff0000-fdffffff ioport:2000(size=64) memory:fd500
000-fd50ffff
 
编辑网卡配置文件
user@vm:/etc/netplan$ cd /etc/netplan/
user@vm:/etc/netplan$ cat ens33.yaml
network:
version: 2
renderer: networkd
ethernets:
ens33:
dhcp4: no
dhcp6: no
optional: true
addresses:
- 192.168.152.136/24
nameservers:
addresses:
- 192.168.152.2
routes:
- to: default
via: 192.168.152.2
 
配置文件权限,不然会警告
user@vm:/etc/netplan$ sudo chmod 600 ens33.yaml
本文地址:https://liuchunjie.top/?id=802
版权声明:本文为原创文章,版权归 admin 所有,欢迎分享本文,转载请保留出处!
NEXT:已经是最新一篇了

评论已关闭!