文件1

Similar documents
MASQUERADE # iptables -t nat -A POSTROUTING -s / o eth0 -j # sysctl net.ipv4.ip_forward=1 # iptables -P FORWARD DROP #

IP505SM_manual_cn.doc

Microsoft Word - XN30Chap3.doc

C3_ppt.PDF

untitled

財金資訊-80期.indd

SEC-220

自由軟體教學平台

網路安全:理論與實務 第二版

A API Application Programming Interface 见 应 用 程 序 编 程 接 口 ARP Address Resolution Protocol 地 址 解 析 协 议 为 IP 地 址 到 对 应 的 硬 件 地 址 之 间 提 供 动 态 映 射 阿 里 云 内

第一章 Linux與網路資源

目 錄 頁 次 政 風 法 令 宣 導 一 行 政 中 立 實 務 探 討 二 收 到 支 付 命 令 不 可 置 之 不 理 3 9 公 務 機 密 維 護 宣 導 一 淺 談 駭 客 攻 擊 14 二 何 不 自 行 設 計 入 侵 防 禦 系 統? 17 安 全 維 護 宣 導 認 識 爆 竹

工程师培训

Symantec™ Sygate Enterprise Protection 防护代理安装使用指南

Simulator By SunLingxi 2003

Windows 2000 Server for T100

ebook140-8

1

ebook71-13

ch09.PDF

GPRS IP MODEM快速安装说明

一、选择题

ext-web-auth-wlc.pdf

<4D F736F F F696E74202D20A1B6CFEEC4BFD2BB20B3F5CAB6BCC6CBE3BBFACDF8C2E7A1B7C8CECEF1C8FD20CAECCFA A1A24950D0ADD2E9BACD4950B5D8D6B72E707074>

¶C¶L§§¬_™¨ A.PDF

LinuxÓû§»ù´¡

05_資源分享-NFS及NIS.doc

ebook140-11

穨CAS1042中文手冊.doc


Linux Ubuntu Part Linux Ubuntu Linux UNIX...19 Linux...19 Linux Linux...21 Linux GNU FSF Open So urce.

Chapter #

D E 答 案 :C 3. 工 作 站 A 配 置 的 IP 地 址 为 /28. 工 作 站 B 配 置 的 IP 地 址 为 /28. 两 个 工 作 站 之 间 有 直 通 线 连 接, 两 台

C6_ppt.PDF

IC-900W Wireless Pan & Tilt Wireless Pan & Tilt Remote Control / Night Vision FCC ID:RUJ-LR802UWG

本文由筱驀釹贡献

前言


BYOD Http Redirect convergence Client (1) 2008R2 NLB( ) (2) NLB Unicast mode switch flooding (arp ) NLB DNS Redirect 1. Round-Robin DNS DNS IP/DNS Cli

飞鱼星多WAN防火墙路由器用户手册

08. Firewall(iptables)

1 Linux Linux Linux Windows NT Linux Linux UNIX Internet Linux Internet Internet Web Linux 26.3% Web Apache 60% Sendmail Internet Linux ISP/ICP

计算机网络概论

TCP/IP TCP/IP OSI IP TCP IP IP TCP/IP TCP/IP

ch08.PDF

第 11 章 互聯網技術 11.1 互聯 網 和 萬 維 網 的 發 展 歷 史 A. 互聯網的發展 互聯網是由 ARPANET 開 始發展的 1969 年 美國國防部高級研究計劃署 (ARPA) 把部分軍事研究所和大 的電腦連接起來 建造了㆒個實驗性的電腦網絡 稱為 ARPANET 並 列 的功能

第 1 章 概 述 1.1 计 算 机 网 络 在 信 息 时 代 中 的 作 用 1.2 计 算 机 网 络 的 发 展 过 程 *1.2.1 分 组 交 换 的 产 生 *1.2.2 因 特 网 时 代 *1.2.3 关 于 因 特 网 的 标 准 化 工 作 计 算 机 网 络 在

9 Internet 10 Internet

IP Access Lists IP Access Lists IP Access Lists

UDP 8.2 TCP/IP OSI OSI 3 OSI TCP/IP IP TCP/IP TCP/IP Transport Control Protocol TCP User Datagram Protocol UDP TCP TCP/IP IP TCP TCP/IP TC

Abstract arm linux tool-chain root NET-Start! 2

11N 无线宽带路由器

Ⅲ. 背 景 資 料 網 路 化 是 現 今 各 產 業 都 無 法 倖 免 的 風 潮 走 進 網 際 網 路 (Internet) 確 實 給 企 業 帶 來 了 許 多 利 基, 包 括 行 銷 企 業 形 象 顧 客 關 係 管 理 (CRM, Customer Relationship M

ebook140-9

NSC-161

Microsoft Word - PS2_linux_guide_cn.doc

1 公 司 简 介 2 VRRP 原 理 和 应 用 3 新 产 品 和 创 业 计 划 及 赠 书 活 动

untitled

ebook62-1

ebook67-9

NetST 2300系列防火墙产品白皮书

SiteView技术白皮书

Web

清华得实WebST网络安全行业解决方案

untitled

PS PS GMM SM.zte.com.

<4D F736F F D20D2F8D0D043444D41CEDECFDFBDD3C8EB41544DBBFAC1AACDF8D3A6D3C3BDE2BEF6B7BDB0B82DD0DEB8C4B0E62E646F63>

epub 61-2

QL1880new2.PDF

untitled

ebook 185-6

1. 二 進 制 數 值 ( ) 2 轉 換 為 十 六 進 制 時, 其 值 為 何? (A) ( 69 ) 16 (B) ( 39 ) 16 (C) ( 7 A ) 16 (D) ( 8 A ) 在 電 腦 術 語 中 常 用 的 UPS, 其 主 要 功 能

untitled

f2.eps

自由軟體社群發展經驗與 Linux認證介紹

1 QoS... 1 QoS... 1 QoS QoS... 5 Class DSCP... 7 CoS... 7 IP QoS... 8 IP / /... 9 Cl

(UTM???U_935_938_955_958_959 V )

Windows 2000 Server for T100

PowerPoint 演示文稿

Data Server_new_.doc

FreeRouter V2 完全手册

1. 請 先 檢 查 包 裝 內 容 物 AC750 多 模 式 無 線 分 享 器 安 裝 指 南 安 裝 指 南 CD 光 碟 BR-6208AC 電 源 供 應 器 網 路 線 2. 將 設 備 接 上 電 源, 即 可 使 用 智 慧 型 無 線 裝 置 進 行 設 定 A. 接 上 電 源

北京市工商局网络安全系统解决方案

ansoft_setup21.doc

SAPIDO GR-1733 無線寬頻分享器

经华名家讲堂

Chap6.ppt

Chapter 2

05 01 X Window X Window Linux Linux X Window X Window Webmin Web Linux Linux X Window X Window Notebook PC X Window X Window module Linux Linux kernel

.. 3 N

untitled

untitled

穨CAS1042快速安速說明.doc

目 彔 1. 准 备 工 作 登 彔 设 置 功 能 说 明 实 时 监 控 基 本 控 制 功 能 设 置 画 质 调 节 彔 像 与 抓 拍

WebSphere Studio Application Developer IBM Portal Toolkit... 2/21 1. WebSphere Portal Portal WebSphere Application Server stopserver.bat -configfile..

<4D F736F F D20C9CFBAA3CAD0BCC6CBE3BBFAB5C8BCB6BFBCCAD4C8FDBCB6BFBCCAD4B4F3B8D95FBDA8D2E9B8E55F5F E646F63>

投影片 1

/3/15 1, linux. linux,,. : 1.NAT ; 2. (load balance, virtual server);; 3. ; 4. ; 5. 6.VPN; 7. ; 8. ; 9.. (,

LSR-120 Router

ebook67-1

Transcription:

iptables log rule policy ( ) 1. (Packet Filter) OSI IP (Router) router router access control list ACL (Transparency) 2. Proxy store-and-forward proxy filter " " 3. Application

internet java script 4. Hardware Software IC 5. Personal Internet CISCOSYSTEMS Router DMZ DMZ (DMZ - Demilitarized Zone) DMZ DNS WWW FTP MAIL rsync DMZ DMZ DMZ iptables linux iptables iptables packet filter 1.

Red Hat Linux RedHat => => shell XTerm GNOME redhat-config-securitylevel DNS DHCP 1023 FTP 20 21 SSH 22 HTTP 80 NFS (2049) NFS X X

(NIS LDAP) PPP eth0 ppp0 iptables /etc/sysconfig/iptables iptables setup->firewall configuration high medium No firewall Customize other port 161 udp 1001 tcp /etc/sysconfig/iptables /etc/init.d/iptables restart iptables -A INPUT -j RH-Lokkit-0-50-INPUT -A FORWARD -j RH-Lokkit-0-50-INPUT -A RH-Lokkit-0-50-INPUT -p udp -m udp --dport 131 -j ACCEPT -A RH-Lokkit-0-50-INPUT -p tcp -m tcp --dport 22 --syn -j ACCEPT -A RH-Lokkit-0-50-INPUT -p udp -m udp -s 0/0 --sport 67:68 -d 0/0 --dport 67:68 -i eth0 -j ACCEPT -A RH-Lokkit-0-50-INPUT -p udp -m udp -s 0/0 --sport 67:68 -d 0/0 --dport 67:68 -i eth1 -j ACCEPT -A RH-Lokkit-0-50-INPUT -i lo -j ACCEPT -A RH-Lokkit-0-50-INPUT -p udp -m udp -s 192.168.10.1 --sport 53 -d 0/0 -j ACCEPT -A RH-Lokkit-0-50-INPUT -p tcp -m tcp --syn -j REJECT -A RH-Lokkit-0-50-INPUT -p udp -m udp -j REJECT COMMIT

iptables L Chain INPUT (policy ACCEPT) target prot opt source destination RH-Lokkit-0-50-INPUT all -- anywhere anywhere Chain FORWARD (policy ACCEPT) target prot opt source destination RH-Lokkit-0-50-INPUT all -- anywhere anywhere Chain OUTPUT (policy ACCEPT) target prot opt source destination Chain RH-Lokkit-0-50-INPUT (2 references) target prot opt source destination ACCEPT udp -- anywhere anywhere udp dpt:131 ACCEPT tcp -- anywhere anywhere tcp dpt:ssh flags:syn,rst,ack/syn ACCEPT udp -- anywhere anywhere udp spts:bootps:bootpc dpts:bootps:bootpc ACCEPT udp -- anywhere anywhere udp spts:bootps:bootpc dpts:bootps:bootpc ACCEPT all -- anywhere anywhere ACCEPT udp -- 192.168.10.1 anywhere udp spt:domain REJECT tcp -- anywhere anywhere tcp flags:syn,rst,ack/syn reject-with icmp-port-unreachable REJECT udp -- anywhere anywhere udp reject-with icmp-port-unreachable /etc/sysconfig/iptables 2. iptables linux router packet filter firewall router firewall router pc router+firewall pc linux IP IP echo 1 > /proc/sys/net/ipv4/ip_forward PC route PC router router PC router IP router internet PC router

PC router IP ping 163.17.35.10 iptables iptalbes L chain iptables PREROUTING FORWARD POSTROUTING ROUTING TABLE INPUT LOCAL HOST OUTPUT iptables 5 chain Chains PREROUTING INPUT OUTPUT FORWARD Route Table Route Table Route Table Route Table POSTROUTING> Route Table chain policy ACCEPT DROP ACCEPT DROP iptables iptables TAGET

ACCEPT DROP REJECT REDIRECT QUEUE LOG MARK SNAT / DNAT / DROP ICMP port unreachable port ( queue ) NAT Source Socket MASQUERADE Destination Socket Source Socket iptables ( ) ( -N ) ( ) ( -X ) ( -P ) ( -L ) ( ) ( -F ( zero ) ( byte ) ( -Z ) ( append ) ( -A ) ( insert ) ( -I ) ( replace ) ( -R ) ( delete ) ( -D ) (delete) (-D) iptables pattern pattern target ( INPUT OUTPUT FORWARD ) ( -i -o ) ( -p ) ( -m state ) ( --syn ) ( -s ) ( --sport ) ( -d ) ( --dport ) iptables -A INPUT -i eth0 -p tcp dport 80 -j ACCEPT

eth0 tcp port 80 localhost iptables -A FORWARD -i ppp0 -p TCP -s xxx.xxx.xxx.xxx -d yyy.yyy.yyy.yyy -j DROP ppp0 tcp ip= xxx.xxx.xxx.xxx ip= yyy.yyy.yyy.yyy NAT IP RFC1918 IP Private IP IP Address Private IP Address routing information Private IP Address Private IP Address IP RFC 1918 Private IP address 10.0.0.0-10.255.255.255 172.16.0.0-172.31.255.255 192.168.0.0-192.168.255.255 IP IP Internet IP Public IP public IP private IP private IP NAT network address transition iptables NAT NAT IP iptables iptables shell script /etc/rc.d/rc.local linux iptables script script script script chmod +x script_filename script http://www.adj.idv.tw/server/linux_nat.htm 1 IP firewall ipt_router1 #!/bin/bash # # Script name: ipt_route1 # A simple script for firewall, used in Linux (kernel 2.4.x), # with certain services provided to outside world. #

# Copyleft 2002 by netman (netman@study-area.org). # # Redistribution of this file is permitted under the terms of # the GNU General Public License (GPL). # # Date: 2002/07/03 # Version: 1.4 # modify by jim hwang 2003/7 PATH=/sbin:/usr/sbin:/bin:/usr/bin EXT_IF=eth0 INT_IF=eth1 FIREWALL_TRUSTED_TCP_PORT="22 80" FIREWALL_TRUSTED_UDP_PORT="53" FIREWALL_ALLOWED_ICMP="0 3 3/4 4 11 12 14 16 18" TRUSTED_TCP_PORT="20 21 22 25 53 80 110" TRUSTED_UDP_PORT="53" ALLOWED_ICMP="0 3 3/4 4 11 12 14 16 18 8" # # ------------- ensure iptables ---------- which iptables &>/dev/null { echo echo "$(basename $0): iptables program is not found." echo " Please install the program first." echo exit 1 } # ------------- disable ipchains ---------- lsmod grep ipchains &>/dev/null && { echo "Disabling ipchains..." rmmod ipchains } # ------------- modules ----------- echo "Loading modules..." modprobe ip_tables &>/dev/null {

echo -n "$(basename $0): loading ip_tables module failure." echo " Please Fix it!" exit 3 } for file in /lib/modules/`uname -r`/kernel/net/ipv4/netfilter/ip_conntrack_*.o do module=$(basename $file) modprobe ${module%.*} &>/dev/null for file in /lib/modules/`uname -r`/kernel/net/ipv4/netfilter/ip_nat_*.o do module=$(basename $file) modprobe ${module%.*} &>/dev/null # ------------- ipforwarding ----------- echo "Turning on IP forwarding..." echo "1" > /proc/sys/net/ipv4/ip_forward # ------------- anti spoofing ----------- echo "Turning on anti-spoofing..." for file in /proc/sys/net/ipv4/conf/*/rp_filter; do echo "1" > $file # ------------- flushing ---------- echo "Cleaning up..." iptables -F -t filter iptables -X -t filter iptables -Z -t filter iptables -F -t nat iptables -X -t nat iptables -Z -t nat # ------------- policies ------------- echo "Setting up policies to ACCEPT..." iptables -P INPUT ACCEPT iptables -P OUTPUT ACCEPT iptables -P FORWARD ACCEPT iptables -t nat -P PREROUTING ACCEPT

iptables -t nat -P POSTROUTING ACCEPT iptables -t nat -P OUTPUT ACCEPT # ------------- FIREWALL ICMP ------------- echo "Creating FIREWALLicmpfilter chain..." iptables -N firewallicmpfilter for TYPE in $FIREWALL_ALLOWED_ICMP; do iptables -A firewallicmpfilter -i $EXT_IF -p icmp \ --icmp-type $TYPE -j ACCEPT # ------------- FIREWALL services ------------ echo "Creating services chain..." iptables -N firewallservices for PORT in $FIREWALL_TRUSTED_TCP_PORT; do iptables -A firewallservices -i $EXT_IF -p tcp --dport $PORT -j ACCEPT for PORT in $FIREWALL_TRUSTED_UDP_PORT; do iptables -A firewallservices -i $EXT_IF -p udp --dport $PORT -j ACCEPT # ------------- ICMP ------------- echo "Creating icmpfilter chain..." iptables -N icmpfilter for TYPE in $ALLOWED_ICMP; do iptables -A icmpfilter -i $EXT_IF -p icmp \ --icmp-type $TYPE -j ACCEPT # ------------- services ------------ echo "Creating services chain..." iptables -N services for PORT in $TRUSTED_TCP_PORT; do iptables -A services -i $EXT_IF -p tcp --dport $PORT -j ACCEPT for PORT in $TRUSTED_UDP_PORT; do iptables -A services -i $EXT_IF -p udp --dport $PORT -j ACCEPT # ------------- block -------------

echo "Creating block chain..." iptables -N block iptables -A block -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A block -m state --state NEW -i! $EXT_IF -j ACCEPT #iptables -A block -j LOG --log-level warning --log-prefix "fw-drop: " iptables -A block -j DROP # ------------- filter ------------- echo "Filtering packets..." iptables -A INPUT -j firewallicmpfilter iptables -A INPUT -j firewallservices iptables -A INPUT -j block iptables -A FORWARD -j icmpfilter iptables -A FORWARD -j services iptables -A FORWARD -j block exit 0 ## EOS 2. ACCEPT server ip service services ICMP # -----setup filter policy for each IP iptables -N icmpfilter iptables -N services DIP_LIST="163.17.40.4 163.17.40.199 163.17.40.81" TRUSTED_TCP_PORT="22 25 110 80" TRUSTED_UDP_PORT="" ALLOWED_ICMP="0 3 3/4 4 11 12 14 16 18 8" for DIP in $DIP_LIST; do for TYPE in $ALLOWED_ICMP; do iptables -A icmpfilter -i $EXT_IF -p icmp \ -d $DIP --icmp-type $TYPE -j ACCEPT for PORT in $TRUSTED_TCP_PORT; do iptables -A services -i $EXT_IF -p tcp -d $DIP --dport $PORT -j ACCEPT

# for PORT in $TRUSTED_UDP_PORT; do # iptables -A services -i $EXT_IF -p udp $DIP --dport $PORT -j ACCEPT # ipt_route2 IP IP NAT head IP IP $EXT_IF ip iptables -t nat -A POSTROUTING -o $EXT_IF -j MASQUERADE ADSL A B D IP 10.111.xxx.xxx IP linux route iptables NAT iptables squid proxy proxy proxy proxy server proxy iptables squid squid work /etc/squid/squid.conf httpd_accel_host localhost.localdomain httpd_accel_port 80 httpd_accel_with_proxy on httpd_accel_uses_host_header on /etc/init.d/squid restart squid iptables iptables -t nat -A PREROUTING -i $INT_IF -p tcp -m tcp \ --dport 80 -j REDIRECT --to-ports 3128 proxy # squid ipt_server ipt_server EXT_IF=ppp0 INT_IF=eth0 ADSL script linux IP Layer 3 L3 L2 iptables eth0:1 eth0 EXT_IF=eth0 INT_IF=eth0 -i interface -s

-s! 192.168.0.0/24 s 192.168.0.0/24 block IP 192.168.0.0/24 forward iptables -A block -s 192.168.0.0/24 -j ACCEPT iptables -A block -m state --state NEW -s 192.168.0.0/24 -j ACCEPT POSTROUTING ip source access NAT port 80 iptables -t nat -A PREROUTING -d 192.168.0.254 \ -p tcp -m tcp --dport 80 -j ACCEPT iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j SNAT --to 163.17.40.5 iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE server forwarding firewall iptables -A PREROUTING -t nat -i eth0 -p tcp -d 163.17.35.10 --dport 80 -j DNAT --to-destination 192.168.0.2:80 iptables -A PREROUTING -t nat -i eth0 -p tcp -d 163.17.35.10 --dport 80 -j DNAT --to-destination 192.168.0.2-192.168.0.3:80 log block iptables -A block -j DROP iptables -A block -j LOG --log-level warning --log-prefix "fw-drop: " DROP /var/log/messages Jul 31 07:57:57 firewall2 kernel: fw-drop: IN=eth1 OUT=eth0 SRC=203.168.249.64 DST=163.17.40.18 LEN=1052 TOS=0x00 PREC=0x00 TTL=103 ID=3073 PROTO=UDP SPT=2390 DPT=135 LEN=1032 Jul 31 07:57:57 firewall2 kernel: fw-drop: IN=eth1 OUT=eth0 SRC=203.168.249.64 DST=163.17.40.13 LEN=1052 TOS=0x00 PREC=0x00 TTL=103 ID=3074 PROTO=UDP SPT=2388 DPT=135 LEN=1032 Jul 31 07:57:57 firewall2 kernel: fw-drop: IN=eth1 OUT=eth0 SRC=203.168.249.64 DST=163.17.40.9 LEN=1052 TOS=0x00 PREC=0x00 TTL=103 ID=3075 PROTO=UDP SPT=2391 DPT=135 LEN=1032

log firewall log firewall fwanalog http://tud.at/programm/fwanalog/ fwanalog firewall log IP Filter iptables ipchain ZyXEL/NetGear routers Cisco PIX Watchguard Firebox Firewall-One firewalls. Analog http://www.analog.cx/ cd /usr/local/src wget http://www.trilithium.com/software/misc/analog/analog-5.32-1.i686.rpm rpm ivh analog-5.32-1.i686.rpm fwanalog wget http://tud.at/programm/fwanalog/fwanalog-0.6.3.tar.gz tar zxvf fwanalog-0.6.3.tar.gz cd fwanalog-0.6.3.tar.gz cp fwanalog.opts.linux24 fwanalog.opts # fwanalog.opts outdir="/var/www/html/fwanalog" #log./fwanalog.sh alldates.html lastweek.html today.html crontab e * 0 * * * /usr/local/src/fwanalog-0.6.3/fwanalog.sh