Brief description: there is no ready-made iptables script in Ubuntu like in The RedHat series. You need to write it manually. So let's get one. One is provided below. Second, you need to install attachment software to control sysV. For example, rcconf can be automatically run by adding the script to/etc/init. d. The script is as follows :#! /Bin/bashcase "$1" instart)
Brief description: there is no ready-made iptables script in Ubuntu like in The RedHat series. You need to write it manually. So let's get one. One is provided below. Second, install attachment software to control sys V.
. For example, rcconf can be automatically run by adding the script to/etc/init. d.
The script is as follows:
#! /Bin/bash
Case "$1" in
Start)
Echo-n "Staring to write your Iptbales :..."
/Sbin/iptables-P INPUT DROP
/Sbin/iptables-P OUTPUT ACCEPT
/Sbin/iptables-a input-I lo-j ACCEPT
/Sbin/iptables-a input-p icmp-m icmp -- icmp-type 8-j DROP
/Sbin/iptables-a input-p tcp-m tcp -- dport 21-j ACCEPT
/Sbin/iptables-a input-p tcp-m tcp -- dport 22-j ACCEPT
/Sbin/iptables-a input-p tcp-m tcp -- dport 80-j ACCEPT
/Sbin/iptables-a input-p tcp-m tcp -- dport 3306-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"
;;
Stop)
Echo-n "Cleaning your Iptables :..."
/Sbin/iptables-F
/Sbin/iptables-X
/Sbin/iptables-Z
Echo "OK"
;;
Restart)
Echo-n "Cleaning your Iptables :..."
/Sbin/iptables-F
/Sbin/iptables-X
/Sbin/iptables-Z
Echo "OK"
Echo-n "Staring to write your Iptbales :..."
/Sbin/iptables-P INPUT DROP
/Sbin/iptables-P OUTPUT ACCEPT
/Sbin/iptables-a input-I lo-j ACCEPT
/Sbin/iptables-a input-p icmp-m icmp -- icmp-type 8-j DROP
/Sbin/iptables-a input-p tcp-m tcp -- dport 20-j ACCEPT
/Sbin/iptables-a input-p tcp-m tcp -- dport 22-j ACCEPT
/Sbin/iptables-a input-p tcp-m tcp -- dport 80-j ACCEPT
/Sbin/iptables-a input-p tcp-m tcp -- dport 3306-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 | stop | restart }"
Esac
Exit 0
Add to other startup levels
Apt-get install rcconf
By kook@52zhe.cn
Address: http://www.52zhe.cn/read.php/156.htm
Copyright: GNU. During reprinting, please note that "reposted" owes me a meal and redeem it when you come to the next day! Thank you for your cooperation!