在Debian中,ifconfig
已弃用,建议使用ip
命令或netplan
等工具。若需使用ifconfig
,可参考以下优化设置:
net-tools
已安装(含ifconfig
命令)。sudo apt update && sudo apt install net-tools -y
/etc/network/interfaces
文件,设置IP、子网掩码、网关等。auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
sudo ifconfig eth0 up # 启用
sudo ifconfig eth0 down # 禁用
sudo ifconfig eth0 mtu 1500
/etc/sysctl.conf
,调整TCP窗口大小、启用TCP优化等。net.core.rmem_max=16777216
net.ipv4.tcp_tw_reuse=1
sudo sysctl -p
注意:ifconfig
功能有限,复杂场景建议使用ip
命令(如ip addr add
配置IP)或netplan
(适用于Debian 10+)。修改前建议备份配置文件,并在测试环境验证。