Difference between revisions of "Bridge Firewall Linux"

From MS Computech
Jump to: navigation, search
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
Bridge Firewall Linux  
 
Bridge Firewall Linux  
  
ผมใช้วิธีนี้ติดตั้งบน Debian etch.   
+
ผมใช้วิธีนี้ติดตั้งบน Debian 7 8 9   
 
<pre># apt-get install bridge-utils</pre>
 
<pre># apt-get install bridge-utils</pre>
&nbsp;นำConfig ทั้งหมดไส่ใน&nbsp;'''/etc/rc.local'''
+
Edit Config ใน&nbsp;'''/etc/rc.local'''
 
<pre>
 
<pre>
 
nano /etc/rc.local
 
nano /etc/rc.local
Line 22: Line 22:
 
</pre>
 
</pre>
  
&nbsp;ติดตั้ง vuurmuur&nbsp;iptables gui&nbsp;สำหรับวิธีการติดตั้ง&nbsp;&gt;&gt;&nbsp;[http://www.vuurmuur.org/trac/wiki/InstallationDebian Debian&amp;Ubuntu].&nbsp;
+
Enable kernel 4.9 bridge filter หากไม่ทำการโหลดโมดูล Bridge จะเป็นแค่ Layer 2 Switch ไม่สามารถ Filter ข้อมูลได้
 
+
<pre>
&nbsp;ตัวอย่างการกำหนด Rule เพิ่มเติมครับ.  
+
modprobe br_netfilter
<pre> iptables -F FORWARD
+
depmod -a
iptables -P FORWARD DROP
+
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -s 0.0.0.0/0.0.0.0 -d 0.0.0.0/0.0.0.0 -m state --state INVALID -j DROP
 
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
 
 
# Some funny rules but not in a classic Iptables sorry ...
 
# Limit ICMP
 
# iptables -A FORWARD -p icmp -m limit --limit 4/s -j ACCEPT
 
# Match string, a good simple method to block some VIRUS very quickly
 
# iptables -I FORWARD -j DROP -p tcp -s 0.0.0.0/0 -m string --string "cmd.exe"
 
 
# Block all MySQL connection just to be sure
 
iptables -A FORWARD -p tcp -s 0/0 -d 62.3.3.0/24 --dport 3306 -j DROP
 
 
# Linux Mail Server Rules
 
 
# Allow FTP-DATA (20), FTP (21), SSH (22)
 
iptables -A FORWARD -p tcp -s 0.0.0.0/0 -d 62.3.3.27/32 --dport 20:22 -j ACCEPT
 
 
# Allow the Mail Server to connect to the outside
 
# Note: This is *not* needed for the previous connections
 
# (remember: stateful filtering) and could be removed.
 
iptables -A FORWARD -p tcp -s 62.3.3.27/32 -d 0/0 -j ACCEPT
 
 
# WWW Server Rules
 
 
# Allow HTTP ( 80 ) connections with the WWW server
 
iptables -A FORWARD -p tcp -s 0.0.0.0/0 -d 62.3.3.28/32 --dport 80 -j ACCEPT
 
 
# Allow HTTPS ( 443 ) connections with the WWW server
 
iptables -A FORWARD -p tcp -s 0.0.0.0/0 -d 62.3.3.28/32 --dport 443 -j ACCEPT
 
 
# Allow the WWW server to go out
 
# Note: This is *not* needed for the previous connections
 
# (remember: stateful filtering) and could be removed.
 
iptables -A FORWARD -p tcp -s 62.3.3.28/32 -d 0/0 -j ACCEPT
 
 
 
 
 
 
</pre>
 
</pre>

Latest revision as of 19:27, 16 March 2019

Bridge Firewall Linux

ผมใช้วิธีนี้ติดตั้งบน Debian 7 8 9 

# apt-get install bridge-utils

Edit Config ใน /etc/rc.local

nano /etc/rc.local
# Bridge Interface

ifconfig eth0 down
ifconfig eth1 down
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 eth1
brctl stp br0 on
ifconfig eth0 0.0.0.0 up
ifconfig eth1 0.0.0.0 up
ifconfig br0 192.168.1.107 netmask 255.255.255.0 up
route add default gw 192.168.1.1

Enable kernel 4.9 bridge filter หากไม่ทำการโหลดโมดูล Bridge จะเป็นแค่ Layer 2 Switch ไม่สามารถ Filter ข้อมูลได้

modprobe br_netfilter
depmod -a
echo 1 > /proc/sys/net/ipv4/ip_forward