ifconfig
命令在 Debian 系统中用于配置、激活和查询网络接口的参数
#!/bin/bash
interfaces=$(ifconfig -a | grep -o '^[^ ]\+')
for interface in $interfaces; do
echo "Interface: $interface"
ifconfig $interface
echo ""
done
#!/bin/bash
interface="eth0"
ip_address="192.168.1.100"
netmask="255.255.255.0"
ifconfig $interface $ip_address netmask $netmask
#!/bin/bash
interface="eth0"
ifconfig $interface down
#!/bin/bash
interface="eth0"
ifconfig $interface up
#!/bin/bash
interface="eth0"
ip_address="192.168.1.100"
ifconfig $interface del $ip_address
请注意,ifconfig
命令在某些 Debian 版本中可能已被弃用,建议使用 ip
命令替代。上述脚本可以根据需要进行相应的修改。