Bridge Firewall 筆記 – br-add.sh (備援)

br-add.sh (建立本機bridge)

#!/bin/bash
# 宣告使用指令之路徑
IPTABLES="/sbin/iptables"



BRCTL="/usr/sbin/brctl"
IFCONFIG="/sbin/ifconfig"
ROUTE="/sbin/route"
# 宣告欲設定之ip資訊
BRIP="X.X.X.X"
FW_IP="X.X.X.X"
BRMASK="X.X.X.X"
GATEWAY="X.X.X.X"
BRBROADCAST="X.X.X.X"
# 宣告欲使用之介面名稱
FW_IFACE="br0"

$BRCTL addbr br0
$BRCTL addif br0 eth0
$BRCTL addif br0 eth1
$BRCTL addif br0 eth3

# 先關閉這三組網路介面
$IFCONFIG br0 down
$IFCONFIG eth0 down
$IFCONFIG eth1 down
$IFCONFIG eth3 down

$IFCONFIG eth0 0.0.0.0
$IFCONFIG eth1 192.168.1.14
$IFCONFIG eth3 0.0.0.0

$IFCONFIG br0 $BRIP netmask $BRMASK broadcast $BRBROADCAST
# 設定 gateway 值,使 fw 本身可以上網 
$ROUTE add default gw $GATEWAY

# 啟動封包轉送
echo "1" > /proc/sys/net/ipv4/ip_forward
This entry was posted in Linux, Network. Bookmark the permalink.