在较新的 Debian 版本中,ifconfig 命令已被弃用,取而代之的是 ip 命令。不过,如果您仍在使用基于 Debian 的系统且需要使用 ifconfig 命令,可以按照以下步骤进行有线网络连接设置:
sudo apt update
sudo apt install net-tools -y
nano)编辑 /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
这里,address 是您要设置的静态 IP 地址,netmask 是子网掩码,gateway 是网关地址。
sudo systemctl restart networking
或者,如果您想手动设置 IP 地址和网关,可以使用以下配置:
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
ping www.google.com
请注意,使用 ifconfig 命令在较新的 Debian 版本中可能不会安装或可用。在这种情况下,建议使用 ip 命令或更新到支持 ifconfig 的 Debian 版本。