VMware Fusion Debian12虚拟机静态IP设置

发布时间 2023-08-26 10:59:49作者: chenxii81

在 VMware Fusion 中安装了 Debian12,设置静态 IP 后 ping 不通外部网络:

/etc/network/interfaces 配置

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
# allow-hotplug ens33
# iface ens33 inet dhcp
# This is an autoconfigured IPv6 interface
# iface ens33 inet6 auto

# static ip config
auto ens33
iface ens33 inet static
address 192.168.31.150/24
gateway 192.168.31.1
dns-nameservers 192.168.31.1
dns-search local

使用 ip addr 查看网卡信息,IP 地址没有问题。

看了 Linux虚拟机(VMware)debian系统设置固定IP 这个文章之后才知道还要设置 /etc/resolv.conf
修改 nameserver 配置如下:

nameserver 192.168.31.1

使用 sudo systemctl restart networking.service 重启网络之后,就可以访问外部网络了。