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
命令替代。上述腳本可以根據需要進行相應的修改。