在Debian虚拟机中设置静态IP地址可以通过以下几种方法:
/etc/network/interfaces
文件配置静态IP/etc/network/interfaces
文件:sudo nano /etc/network/interfaces
eth0
:auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4
请根据您的网络环境更改IP地址、子网掩码、网关和DNS服务器。sudo systemctl restart networking
ip addr show eth0
或ifconfig
nmcli
命令行工具配置静态IPip addr show
nmcli
命令为网络接口配置IP地址:sudo nmcli connection modify "Wired connection 1" ipv4.addresses "192.168.1.100/24" ipv4.gateway "192.168.1.1" ipv4.dns "8.8.8.8 8.8.4.4"
请根据您的网络环境更改IP地址、子网掩码、网关和DNS服务器。sudo nmcli connection up "Wired connection 1"
ip addr show eth0
或ifconfig
以上步骤应该涵盖了在Debian虚拟机中设置静态IP地址的主要方法。请根据您的实际情况选择合适的方法进行配置。