在较新的 Debian 版本中,ifconfig 命令已被弃用,取而代之的是 ip 命令。不过,如果你仍然需要使用 ifconfig 命令,可以通过安装 net-tools 软件包来获得。
sudo apt update
sudo apt install net-tools
使用 ifconfig 命令查看所有可用的网络接口及其详细信息:
ifconfig
或者使用 ip 命令:
ip addr show
网络接口配置文件通常位于 /etc/network/interfaces。使用文本编辑器(如 nano)编辑该文件:
sudo nano /etc/network/interfaces
在配置文件中添加以下内容来配置静态IP地址(以 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
使用 ifconfig 或 ip addr 命令检查网络接口的配置是否正确:
ip addr show eth0
或者
ifconfig eth0
使用 ping 命令测试网络连接是否正常:
ping www.google.com
如果能够成功 ping 通目标地址,则说明网络连接配置成功。
请注意,上述步骤适用于使用 net-tools 的较旧 Debian 版本。在较新的 Debian 版本中,建议使用 ip 命令来管理网络配置。