在 Debian 中,ifconfig 默认可能 没有安装,而且在新版 Debian 中更推荐使用 ip 命令。下面分情况说明:
sudo apt update
sudo apt install net-tools
安装完成后即可使用:
ifconfig
ifconfig -a
或
ip addr
sudo ifconfig eth0 up
sudo ifconfig eth0 down
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0 up
sudo ip link set eth0 up
sudo ip addr add 192.168.1.100/24 dev eth0
编辑:
sudo nano /etc/network/interfaces
示例(DHCP):
auto eth0
iface eth0 inet dhcp
或静态 IP:
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
重启网络:
sudo systemctl restart networking
如果你告诉我 Debian 版本 和 网卡名称,我可以给你更精确的命令。