系统版本
cat /proc/version
Linux version 5.15.0-67-generic (buildd@lcy02-amd64-116) (gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #74-Ubuntu SMP Wed Feb 22 14:14:39 UTC 2023
VMware 虚拟机中安装 Ubuntu Server 20.04,配置桥接模式,配置静态IP
1、编辑 /etc/netpaln/
目录下的配置文件(我的是00-installer-config.yaml
可能还有其它名字?)
配置文件默认内容如下:
root@server:~$ cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
ens33:
dhcp4: true
version: 2
2、在此目录里面输入以下信息,注意参数之间的层次,一定要区别开,不然参数会不生效的:
# This is the network config written by 'subiquity'
network:
ethernets:
ens33:
dhcp4: no
addresses: [192.168.6.133/24]
optional: true
gateway4: 192.168.6.1
nameservers:
addresses: [114.114.114.114]
3、执行 sudo netplat apply
命令,让配置生效,为什么有如下的告警信息?
4、查看配置是否生效
root@server:~$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.6.133 netmask 255.255.255.0 broadcast 192.168.6.255
inet6 fe80::20c:29ff:fe97:804e prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:97:80:4e txqueuelen 1000 (Ethernet)
RX packets 579 bytes 61919 (61.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 719 bytes 79254 (79.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 2919 bytes 210852 (210.8 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2919 bytes 210852 (210.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
root@server:~$