首页 > iptabes, linux > ubuntu iptables 脚本

ubuntu iptables 脚本

2010年1月28日 eric 发表评论 阅读评论

            谈下我的 iptables 规则.

#!/bin/bash
case “$1″ in
start)
echo -n “Staring to write your Iptbales:…”
/sbin/iptables -F
/sbin/iptables -X
/sbin/iptables -Z

/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o eth0 -p icmp -j ACCEPT
iptables -A INPUT -i eth0 -p icmp –icmp-type echo-reply -j ACCEPT
iptables -t filter -A INPUT -p icmp -s 111.111.111.111 -j ACCEPT
iptables -A INPUT -i eth0 -p icmp -j REJECT –reject-with icmp-host-unreachable
/sbin/iptables -A INPUT -p tcp -m tcp –dport 80 -j ACCEPT
/sbin/iptables -A INPUT -p tcp -i eth0 -s 111.111.111.111/32 –destination-port 555 -j ACCEPT
/sbin/iptables -A INPUT -p all -m state –state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A INPUT -p all -m state –state INVALID,NEW -j DROP
echo “Ok”

;;
*)
echo “Usage: $0 {start}”
esac

exit 0

上面的规则 icmp 只允许 111.111.111.111 的ping 其他人ping 服务器,返回伪造的icmp-host-unreachable 信息

开放 80 端口供任何人访问,开放 555端口 只允许 111.111.111.111 访问

我把 SSH 端口设置为 555 因为有很多无聊的人都在每天扫描着  22 端口很烦~~

iptables 的规则要有顺序,如果顺序杂乱虽然可以使用,但是也会引起一些瓶径“导致服务器访问速度下降!!

转载请注明:文章转载自:Eric's linux and nginx! (http://www.nginxs.com)
本文地址:http://www.nginxs.com/linux/51.html

分类: iptabes, linux 标签: , , ,
  1. 2017年12月29日04:21 | #1

    Hey would you mind letting me know which webhost you’re working with?
    I’ve loaded your blog in 3 different browsers and I must say this blog loads a lot faster then most.
    Can you recommend a good internet hosting provider at a fair price?
    Thank you, I appreciate it!

  2. 2018年1月19日22:46 | #2

    I have been exploring for a bit for any high quality articles or weblog posts in this kind of house .

    Exploring in Yahoo I eventually stumbled upon this website.
    Reading this info So i’m satisfied to show that
    I have a very good uncanny feeling I came upon just what I needed.
    I so much definitely will make certain to do not
    overlook this website and provides it a look regularly.

  3. 2018年1月22日14:39 | #3

    Hey very interesting blog!

  4. 2018年1月23日18:54 | #4

    You are so interesting! I don’t think I’ve read through something like this before.
    So nice to discover another person with some original thoughts on this subject matter.
    Seriously.. thank you for starting this up.
    This web site is one thing that is required
    on the internet, someone with a little originality!

  5. 2018年2月8日01:05 | #5

    It’s very trouble-free to find out any topic
    on web as compared to textbooks, as I found this article at this
    web page.

  6. 2018年2月10日06:59 | #6

    Hi there mates, how is everything, and what you desire to say
    about this paragraph, in my view its actually awesome in support of me.

  7. 2018年2月10日12:43 | #7

    Glorioso Tree Service is a UNBELIEVABLE company.

  8. 2018年2月10日13:54 | #8

    Use this tool to remove small branches and twigs.

  9. 2018年2月14日20:31 | #9

    Renting a limousine for an evening out is fun.

评论分页
1 2 3 4 51
订阅评论
5+8= (必填)