IPTABLES-SAVE手冊頁&IPTABLES-RESTORE手冊頁
總覽
iptables-save [-c] [-t table]
說明
透過簡單的語法格式把一個IP TABLE的內容轉儲到STDOUT(標準輸出).可以
用由shell提供I/0重定向寫到一個檔案中
-c, --counters
輸出中包括所有包和位元組計數器的當前值
-t, --table tablename
僅輸出指定表名的那個表,若沒有指定,將輸出所有可用的表
總覽
iptables-restore [-c] [-n]
說明
iptables-restore的作用是透過STDIN(標準輸入)上指定的資料來恢復IP Table。
由你的shell提供的I/O重定向功能從一個檔案中讀取。
-c, --counters
恢復所有包和位元組計數器的當前值
-n, --noflush
不刪除表中以前的內容,如果沒有指定(這一引數),iptables-restore會清空(刪除)所有
以前表中的內容。
/usr/share/doc/iptables/examples/3iptables-ppp_down-rules
/usr/share/doc/iptables/examples/oldinitdscript.gz
/usr/share/doc/iptables/examples/3iptables-ppp_up-rules.gz
可以從上面的地址找到例子。其中oldinitdscript 是對應於希望使用
iptables start/stop/restart
準備的,不過不推薦使用。
如果希望自己控制,可以使用 3iptables-ppp_up-rules 。加到
/etc/ppp/ip-up的最後,不過我使用發現有些問題就是
3iptables-ppp_down-rules 沒有辦法清楚nat的配置,索性我不要了,
將3iptables-ppp_down-rules 修改的面目全非。呵呵。
如下:
程式碼: |
#!/bin/sh # # 3iptables-ppp_up-rules, v0.6 03/09/2003. # Kiryanov Vasiliy, mailto://root@lycos.ru # # Thanks: Uwe Zeisberger - rfc1918 violating fix; # # Many people use ppp to connect to the InterNet, this script set BASIC # firewall (iptables) rules to protect you machine from crackers. # For good protect read iptables(8) manual and tune this script! # FOR USAGE: # put 3iptables-ppp_up-rules script in /etc/ppp/ip-up.d # put 3iptables-ppp_down-rules script in /etc/ppp/ip-down.d # check: scripts owned by root.root and have mode 700. # If you find some errors or missing write me: #-------------------------------------------------------------- # check if iptables exist and have kernel support test -x /sbin/iptables || exit 1 /sbin/iptables --list --numeric >/dev/null 2>&1 test $? -eq 0 || exit 1 # When started pppd it call ip-up, which set variables and uses run-parts # to run scripts in /etc/ppp/ip-up.d, one of which is that. # ip-up set this variables, so we don't need to do it: # Var Name Example INET_IFACE="ppp0" VPN_IFACE="ppp+" LAN_IP="192.168.3.1" LAN_IP_RANGE="192.168.3.0/24" LAN_IFACE="eth0" LO_IFACE="lo" LO_IP="127.0.0.1" IPTABLES="/sbin/iptables" echo "1" > /proc/sys/net/ipv4/ip_forward modprobe ip_tables modprobe ip_nat_ftp modprobe ip_conntrack modprobe ip_conntrack_ftp # PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin #Save iptables exist rulesets, we restore them after PPP interface down! # disable `root group` and `other users` access umask 066 # protect against symbolic link attack test ! -e /tmp/3iptables-ppp_up-SAVE || rm -f /tmp/3iptables-ppp_up-SAVE # save exist ruleset /sbin/iptables-save > /tmp/3iptables-ppp_up-SAVE $IPTABLES -F -t filter $IPTABLES -F -t nat $IPTABLES -A INPUT -p TCP -s 0/0 --dport 21 -j ACCEPT $IPTABLES -A INPUT -p TCP -s 0/0 --dport 22 -j ACCEPT $IPTABLES -A INPUT -p TCP -s 0/0 --dport 80 -j ACCEPT $IPTABLES -A INPUT -p TCP -s 0/0 --dport 113 -j ACCEPT #VPN ACCEPT $IPTABLES -A INPUT -p TCP -s 0/0 --dport 1723 -j ACCEPT $IPTABLES -A INPUT -p ALL -i $VPN_IFACE -j ACCEPT $IPTABLES -A INPUT -p GRE -j ACCEPT $IPTABLES -A INPUT -p UDP --dport 5000 -j ACCEPT $IPTABLES -A INPUT -i tun+ -j ACCEPT $IPTABLES -A FORWARD -i tun+ -j ACCEPT $IPTABLES -A INPUT -i tap+ -j ACCEPT $IPTABLES -A FORWARD -i tap+ -j ACCEPT $IPTABLES -A INPUT -p UDP -s 0/0 --dport 53 -j ACCEPT $IPTABLES -A INPUT -p UDP -s 0/0 --dport 2074 -j ACCEPT $IPTABLES -A INPUT -p UDP -s 0/0 --dport 4000 -j ACCEPT $IPTABLES -A INPUT -p ICMP -s 0/0 --icmp-type 8 -j ACCEPT $IPTABLES -A INPUT -p ICMP -s 0/0 --icmp-type 11 -j ACCEPT $IPTABLES -A INPUT -p ALL -i $LAN_IFACE -j ACCEPT $IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT $IPTABLES -A INPUT -j DROP $IPTABLES -A FORWARD -i $INET_IFACE -j ACCEPT $IPTABLES -A FORWARD -i $LAN_IFACE -j ACCEPT $IPTABLES -A FORWARD -i $VPN_IFACE -j ACCEPT $IPTABLES -A FORWARD -j DROP $IPTABLES -A OUTPUT -p ALL -j ACCEPT $IPTABLES -t nat -A POSTROUTING -s 192.168.3.0/24 -j MASQUERADE $IPTABLES -t nat -A PREROUTING -i eth0 -p tcp -s 192.168.3.0/24 -d ! 192.168.3.1/24 --dport 80 -j REDIRECT --to-ports 3128 # # try '# ifconfig' to see if your ppp interface all right # try '# iptables --list --verbose' to see if all rules right |
不過我還是推薦使用 shorewall ,配置也不復雜,主要是安全性比較高。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/786540/viewspace-1002072/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- iptables-save中文手冊(轉)
- iptables-restore中文手冊(轉)REST
- Rafy 框架-釋出網頁版使用者手冊框架網頁
- 是操作手冊更是安全手冊
- 前端手冊前端
- MongoDB手冊MongoDB
- SparkSQL手冊SparkSQL
- Babel手冊Babel
- HTML手冊HTML
- 工具手冊
- Redis手冊Redis
- 為 man 手冊頁編寫解析器的備忘錄
- DOM參考手冊及事件參考手冊事件
- TypeScript中文手冊TypeScript
- JS速查手冊JS
- MeterSphere開發者手冊
- JVM指令手冊JVM
- PostgreSQLPHP開發者手冊SQLPHP
- python手冊Python
- WEB速查手冊Web
- oracle手冊索引Oracle索引
- ASM管理手冊ASM
- IT公司速查手冊
- JSP註冊頁面JS
- Redis大全手冊(上)Redis
- CMD 命令速查手冊
- jquery操作手冊jQuery
- Redux學習手冊Redux
- 【譯】JavaScript 完整手冊JavaScript
- Redis入門手冊Redis
- xhEditor技術手冊
- Serverless 產品手冊Server
- Docker入門手冊Docker
- [譯] fasthttp 文件手冊ASTHTTP
- NIST 函式手冊函式
- Webpack飛行手冊Web
- HTML_速查手冊HTML
- rpmbuild 中文手冊UI