關於 鳥哥的私房菜的 簡易 Firewall 架設 這篇文章,我照做可是不能用也?? - PCZONE 討論區

返回   PCZONE 討論區 > ▲ -- 電 腦 軟 體 討 論 區 > -- FreeBSD & Linux 討 論 版


PCZONE 討論區



通知

-- FreeBSD & Linux 討 論 版 因為本站採用 FreeBSD 作業系統,所以自己本身也多學了一些技巧,希望各位在這裡互相討論 Unix 作業系統及程式等相關問題。

美麗與智慧並重英
關於 鳥哥的私房菜的 簡易 Firewall 架設 這篇文章,我照做可是不能用也??
我的環境和鳥哥的列子有些不同
我的主機只有一張網卡有實體ip並且我不做nat所以做了以下的修改,如下綠色的部份
我將鳥哥的iptables.rule的某部份的內容

#!/bin/bash
#
# ³o­Ó script ¬O¥Î¨Ó«Ø¥ß iptables ¨¾¤õÀ𪺰ò¥»³W«h¡I
# °ò¥»³W«h©w¸q¬°¡y©Úµ´©Ò¦³¡A¶}©ñ‾S©w¡zªº¼Ò¦¡¡I
# §A¥i¥H±N³o­ÓÀɮשñ¸m¦b /usr/local/virus/iptables ©³¤U¡AÀɦW¥i©w¸q¬° iptables.rule ¡I
# °ò¥»¤W¡A§A¥i¥H°Ñ¦Ò³o­Óºô‾¸¸ê®Æ¡G http://linux.vbird.org
#
# HISTORY:
# 2002/08/20 First release by VBird
#

# 0.0 Please key in your parameters
EXTIF="eth1" # the interface that connect Internet
INIF="" # the inside interface. if you don't have this one
# and you must let this be black ex> INIF=""
INNET="" # This is for NAT's network


# 1.0 Testing your Kernel version and remove the ipchains module
kver=`uname -r | cut -c 1-3`
if [ "$kver" != "2.4" ] && [ "$kver" != "2.5" ]; then
echo "Your Linux Kernel Version may not be suported by this script!"
echo "This scripts will not be runing"
exit
fi
ipchains=`lsmod | grep ipchains`
if [ "$ipchains" != "" ]; then
echo "unload ipchains in your system"
rmmod ipchains 2> /dev/null
fi

# 2.0 Loading some modules
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH EXTIF INIF INNET
modprobe ip_tables > /dev/null 2>&1
modprobe iptable_nat > /dev/null 2>&1
modprobe ip_nat_ftp > /dev/null 2>&1
modprobe ip_nat_irc > /dev/null 2>&1
modprobe ip_conntrack > /dev/null 2>&1
modprobe ip_conntrack_ftp > /dev/null 2>&1
modprobe ip_conntrack_irc > /dev/null 2>&1

# 3.0 Clear the iptables's rules
/sbin/iptables -F
/sbin/iptables -X
/sbin/iptables -Z
/sbin/iptables -F -t nat
/sbin/iptables -X -t nat
/sbin/iptables -Z -t nat
/sbin/iptables -P INPUT ACCEPT
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -P FORWARD ACCEPT
/sbin/iptables -t nat -P PREROUTING ACCEPT
/sbin/iptables -t nat -P POSTROUTING ACCEPT
/sbin/iptables -t nat -P OUTPUT ACCEPT

# 4.0 Allow the lo and inside interface to access the server and internet
# /sbin/iptables -A INPUT -i lo -j ACCEPT
# if [ "$INIF" != "" ]; then
# /sbin/iptables -A INPUT -i $INIF -j ACCEPT
# echo "1" > /proc/sys/net/ipv4/ip_forward
# /sbin/iptables -t nat -A POSTROUTING -s $INNET -o $EXTIF -j MASQUERADE
# fi


# 5.0 Deny and Allow IP or host or network from files
if [ -f /usr/local/virus/iptables/iptables.deny ]; then
/usr/local/virus/iptables/iptables.deny
fi
if [ -f /usr/local/virus/iptables/iptables.allow ]; then
/usr/local/virus/iptables/iptables.allow
fi

# 6.0 Allow ICMP come in
AICMP="0 3 3/4 4 11 12 14 16 18"
for tyicmp in $AICMP
do
/sbin/iptables -A INPUT -i $EXTIF -p icmp --icmp-type $tyicmp -j ACCEPT
done

# 7.0 Allow services
/sbin/iptables -A INPUT -p TCP -i $EXTIF --dport 21 -j ACCEPT # FTP
/sbin/iptables -A INPUT -p TCP -i $EXTIF --dport 22 -j ACCEPT # SSH
/sbin/iptables -A INPUT -p TCP -i $EXTIF --dport 25 -j ACCEPT # SMTP
/sbin/iptables -A INPUT -p UDP -i $EXTIF --dport 53 -j ACCEPT # DNS
/sbin/iptables -A INPUT -p TCP -i $EXTIF --dport 53 -j ACCEPT # DNS
/sbin/iptables -A INPUT -p TCP -i $EXTIF --dport 80 -j ACCEPT # WWW
/sbin/iptables -A INPUT -p TCP -i $EXTIF --dport 110 -j ACCEPT # POP3

# 8.0 Allow RELATED and ESTABLISHED
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# 9.0 deny all
/sbin/iptables -A INPUT -m state --state NEW,INVALID -j DROP



其它的和鳥哥的設定一樣
則得到如下的結果

[root@linux root]# /usr/local/virus/iptables/iptables.rule
bash: /usr/local/virus/iptables/iptables.rule: bad interpreter: No such file or directory
[root@linux root]# lsmod
Module Size Used by
binfmt_misc 6416 1
iscsi 21984 0 (unused)
scsi_mod 95696 1 [iscsi]
autofs 11520 0 (autoclean) (unused)
via-rhine 11424 1
eepro100 17664 1
appletalk 20912 0 (autoclean)
ipx 16448 0 (autoclean)
usb-uhci 21536 0 (unused)
usbcore 51712 1 [usb-uhci]
[root@linux root]#


不能用也,是哪裡出問題呢?

回覆
莫道君行早
一般: 關於 鳥哥的私房菜的 簡易 Firewall 架設 這篇文章,我照做可是不能用也??
引用:
最初由 bigmichael 發表
[B]我的環境和鳥哥的列子有些不同

其它的和鳥哥的設定一樣
則得到如下的結果

[root@linux root]# /usr/local/virus/iptables/iptables.rule
bash: /usr/local/virus/iptables/iptables.rule: bad interpreter: No such file or directory
它不是說了嗎:檔案找不到。
回覆
美麗與智慧並重英
一般: 一般: 關於 鳥哥的私房菜的 簡易 Firewall 架設 這篇文章,我照做可是不能用也??
引用:
最初由 blueshen 發表
它不是說了嗎:檔案找不到。
它明明存在啊!如下:
[root@linux root]# cd /usr/local/virus/iptables/
[root@linux iptables]# ls
iptables.allow iptables.deny iptables.rule
[root@linux iptables]# /usr/local/virus/iptables/iptables.rule
bash: /usr/local/virus/iptables/iptables.rule: bad interpreter: No such file or directory
[root@linux iptables]#

回覆
莫道君行早
一般: 一般: 一般: 關於 鳥哥的私房菜的 簡易 Firewall 架設 這篇文章,我照做可是不能用也??
引用:
最初由 bigmichael 發表
它明明存在啊!如下:
[root@linux root]# cd /usr/local/virus/iptables/
[root@linux iptables]# ls
iptables.allow iptables.deny iptables.rule
[root@linux iptables]# /usr/local/virus/iptables/iptables.rule
bash: /usr/local/virus/iptables/iptables.rule: bad interpreter: No such file or directory
[root@linux iptables]#


你把這個檔案叫進 X-window 的文字編輯器,再存一次檔,看看能不能用。
(可以除去檔案堿搕ㄗㄙ熔顫)
回覆
解決郵件問題會員
一般: 一般: 一般: 關於 鳥哥的私房菜的 簡易 Firewall 架設 這篇文章,我照做可是不能用也??
引用:
最初由 bigmichael 發表
它明明存在啊!如下:
[root@linux root]# cd /usr/local/virus/iptables/
[root@linux iptables]# ls
iptables.allow iptables.deny iptables.rule
[root@linux iptables]# /usr/local/virus/iptables/iptables.rule
bash: /usr/local/virus/iptables/iptables.rule: bad interpreter: No such file or directory
[root@linux iptables]#


檔案有執行的權限嗎???
/usr/local/virus/iptables/iptables.rule

回覆


類似的主題
主題 主題作者 討論版 回覆 最後發表
使用 PPTP 架設 VPN boobee2 ---- ADSL 軟 硬 體 技 術 7 2009-01-08 11:18 AM
簡易 DIY 資訊 ,提升 2.4G 訊號的反射版.(10dBi, 12dBi) bv2lk -- 無 線 網 路 版 5 2008-08-16 11:26 PM
【討論】SEEDNET FTTB 10M/10M SEEDEN 上傳測試 (簡易) 阿 土 -- FTTB / FTTC / FTTH 光纖寬頻討論版 3 2006-05-03 03:28 AM
【求助】請教 apache 架設 VirtualHost addnew -- FreeBSD & Linux 討 論 版 2 2005-12-23 11:53 PM
架設 mdaemon 問題? alvin007 -- 網 路 技 術 版 1 2001-09-03 09:21 AM






 XML   RSS 2.0   RSS 
本站使用 vBulletin 合法版權程式
站務信箱 : [email protected]

本論壇所有文章僅代表留言者個人意見,並不代表本站之立場,討論區以「即時留言」方式運作,故無法完全監察所有即時留言,若您發現文章可能有異議,請 email :[email protected] 處理。