รู้จัก IPTABLES

IPTABLES เป็นซอฟต์แวร์ที่ใช้ทำ Firewall นิยมใช้งานบนระบบ Linux และ BSD

การเปิด-ปิดเซอร์วิส
#service iptables save
#service iptables stop
#service iptables start
#service iptables restart

การทำ NAT อย่างง่าย
ไฟล์ /etc/rc.d/rc.nat1
--------------------------------
# Basic NAT
#!/bin/sh
#
# ThaiNetPro Network Address Translation
# rc.nat2
# Create by A.Arnut Ruttanatirakul
# Updated : October 30, 2006
# ========================================
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
service iptables save
service iptables restart
iptables -L


กรณีใช้ LAN Card 2 ใบ
ไฟล์ /etc/rc.d/rc.nat2
--------------------------------
# Basic NAT
#!/bin/sh
#
# ThaiNetPro Network Address Translation
# rc.nat2
# Create by A.Arnut Ruttanatirakul
# Updated : October 30, 2006
# ========================================
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -P FORWARD DROP
iptables -A POSTROUTING -t nat -s 192.168.10.0/24 -o eth0 -j MASQUERADE
iptables -A FORWARD -d 192.168.10.0/24 -j ACCEPT
iptables -A FORWARD -s 192.168.10.0/24 -j ACCEPT
iptables -A FORWARD -j DROP
service iptables save
service iptables restart


กรณีใช้ LAN Card 2 ใบ สร้างตัวแปรเก็บชื่อแลนการ์ด
ไฟล์ /etc/rc.d/rc.nat3
--------------------------------
# Basic NAT
#!/bin/sh
#
# ThaiNetPro Network Address Translation
# rc.nat3
# Create by A.Arnut Ruttanatirakul
# Updated : October 30, 2006
EX_ETH=eth0 # External Interface
IN_ETH=eth1 # Local Interface
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -F
iptables -t nat -F
# Masquerade
iptables -t nat -A POSTROUTING -o $EX_ETH -j MASQUERADE
service iptables save


กรณีใช้ LAN Card 2 ใบ ทำ NAT ร่วมกับ Proxy Server
ไฟล์ /etc/rc.d/rc.nat4
--------------------------------
#!/bin/sh
#
# ThaiNetPro Network Address Translation
# rc.nat4
# Create by A.Arnut Ruttanatirakul
# Updated : October 30, 2006
# ========================================
EX_ETH=eth0 # External Interface
IN_ETH=eth1 # Local Interface
PROXY_PORT=8080 # Proxy Server Port

echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -F
iptables -t nat -F

# Masquerade
iptables -t nat -A POSTROUTING -o $EX_ETH -j MASQUERADE

# Transparent Proxy
iptables -t nat -A PREROUTING -i $IN_ETH -p tcp --dport 80 -j REDIRECT --to-port $PROXY_PORT

service iptables save


การตรวจสอบ IPTABLES
# iptables -L

#!/Follow me on: