# 開啟 81/tcp iptables -I INPUT -i eth0 -p tcp --dport 81 -j ACCEPT iptables -I OUTPUT -o eth0 -p tcp --sport 81 -j ACCEPT # 關閉 81/tcp iptables -I INPUT -i eth0 -p tcp --dport 81 -j DROP iptables -I OUTPUT -o eth0 -p tcp --sport 81 -j DROP
# ifconfig 指令 ifconfig eth0 up ifconfig eth0 down # 或使用啟動腳本 (Red Hat 系列) /sbin/ifup eth0 /sbin/ifdown eth0
ifconfig eth0 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255
編輯 /etc/sysconfig/network-scripts/ifcfg-eth0:
DEVICE=eth0 BOOTPROTO=static IPADDR=192.168.1.10 NETMASK=255.255.255.0 ONBOOT=yes
建立 ifcfg-eth0:1、ifcfg-eth0:2… 同目錄下,設定不同 IPADDR。
/etc/init.d/network restart # 或 service network restart
臨時測試用 ifconfig/iptables 即時生效;正式環境請修改 /etc/sysconfig/network-scripts/ 下對應檔案並重啟 network 服務。