gentoo 回复于:2003-10-08 10:41:59 |
你认为上面的脚本有用吗! iptables -P FORWARD DROP 后FORWARD链不加任何规则 下面这句有用吗? echo "1" > /proc/sys/net/ipv4/ip_forward 要看清楚INPUT 跟FORWARD 的概念. |
好好先生 回复于:2003-10-08 10:45:48 |
我对iptables不熟悉.这是别人发到我的信箱里的,我贴到这儿了.谢谢帮忙. |
yoyoho 回复于:2003-10-08 10:47:49 |
1.内核编译 一般来讲,透明代理所在机器往往是带动整个局域网联入互联网的入口,因此该机器往往需要配置防火墙规则以对内部网络进行防护。因此在编译内核时也许要考虑将防火墙支持选项编译进去。 rpm -q kernel-headers kernel-source make dev86 #检查RPM包,如果不齐的补齐。 cd /usr/src/linux-xxxx #进入内核所在目录 一般来说需要在使用make menuconfig命令配置时打开如下选项: [*]Networking support [*]Sysctl support [*]Network packet filtering [*]TCP/IP networking [*]/proc filesystem support [*] Kernel/User netlink socket [*] Netlink device emulation 上面的部原本上几乎不用改,以下部份在IP: Netfilter Configuration [*] Connection tracking (required for masq/NAT) [*] FTP protocol support [*] IP tables support (required for filtering/masq/NAT) <*> limit match support [*] MAC address match support [*] Netfilter MARK match support [*] Multiple port match support [*] TOS match support [*] Connection state match support [*] Packet filtering [*] REJECT target support [*] Full NAT [*] MASQUERADE target support [*] REDIRECT target support [*] Packet mangling [*] TOS target support [*] MARK target support [*] LOG target support 然后make dep ; make clean ;make bzImage命令来编译内核。如果使用到了模块,还需要使用下面命令生成和安装模块make modules;make modules-install。 将System.map复制到/boot目录中,将 /usr/src/linux/arch/i386/boot/bzImage复制到 /boot目录中并改名为 vmlinuz-2.4.7-10。最后安装新内核并重新起动:lilo;shutdown -r now即可。 另:/etc/sysconfig/network 为: NETWORKING=yes HOSTNAME="gateway" FORWARD_IPV4=true GATEWAYDEV=eth1 2.iptables的设置 在/etc/rc.d/目录下用touch命令建立firewall文件,执行chmod u+x firewall以更改文件属性,编辑/etc/rc.d/rc.local文件,在末尾加上/etc/rc.d/firewall以确保开机时能自动执行该脚本。 firewall文件内容为: #!/bin/sh echo "Enabling IP Forwarding..." echo 1 > /proc/sys/net/ipv4/ip_forward echo "Starting iptables rules..." #Refresh all chains /sbin/rmmod ipchains /sbin/modprobe ip_tables /sbin/modprobe iptable_filter /sbin/modprobe iptable_nat /sbin/modprobe ip_conntrack /sbin/modprobe ip_conntrack_ftp /sbin/modprboe ip_nat_ftp /sbin/iptables -F INPUT /sbin/iptables -F FORWARD /sbin/iptables -F POSTROUTING -t nat /sbin/iptables -P FORWARD DROP #/sbin/iptables -t nat -A POSTROUTING -o eth1 -s 192.168.1.0/24 -j MASQUERADE #eth1为接Internet的网卡 /sbin/iptables –t nat –A POSTROUTING –o ppp0 –j MASQUERADE #用于ppp0拨号 /sbin/iptables -A FORWARD -i eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT /sbin/iptables -A FORWARD -s 192.168.1.0/24 -j ACCEPT |
好好先生 回复于:2003-10-08 10:51:13 |
谢谢! |