Untitled

From Anonymous, 3 Years ago, written in Plain Text, viewed 56 times.
URL https://paste.bugabuse.net/view/21074326 Embed
Download Paste or View Raw
  1. #!/bin/sh
  2. #
  3. # Generated iptables firewall script for the Linux 2.4 kernel
  4. # Script generated by Easy Firewall Generator for IPTables 1.15
  5. # copyright 2002 Timothy Scott Morizot
  6. #
  7. # Redhat chkconfig comments - firewall applied early,
  8. #                             removed late
  9. # chkconfig: 2345 08 92
  10. # description: This script applies or removes iptables firewall rules
  11. #
  12. # This generator is primarily designed for RedHat installations,
  13. # although it should be adaptable for others.
  14. #
  15. # It can be executed with the typical start and stop arguments.
  16. # If used with stop, it will stop after flushing the firewall.
  17. # The save and restore arguments will save or restore the rules
  18. # from the /etc/sysconfig/iptables file.  The save and restore
  19. # arguments are included to preserve compatibility with
  20. # Redhat's or Fedora's init.d script if you prefer to use it.
  21.  
  22. # Redhat/Fedora installation instructions
  23. #
  24. # 1. Have the system link the iptables init.d startup script into run states
  25. #    2, 3, and 5.
  26. #    chkconfig --level 235 iptables on
  27. #
  28. # 2. Save this script and execute it to load the ruleset from this file.
  29. #    You may need to run the dos2unix command on it to remove carraige returns.
  30. #
  31. # 3. To have it applied at startup, copy this script to
  32. #    /etc/init.d/iptables.  It accepts stop, start, save, and restore
  33. #    arguments.  (You may wish to save the existing one first.)
  34. #    Alternatively, if you issue the 'service iptables save' command
  35. #    the init.d script should save the rules and reload them at runtime.
  36. #
  37. # 4. For non-Redhat systems (or Redhat systems if you have a problem), you
  38. #    may want to append the command to execute this script to rc.local.
  39. #    rc.local is typically located in /etc and /etc/rc.d and is usually
  40. #    the last thing executed on startup.  Simply add /path/to/script/script_name
  41. #    on its own line in the rc.local file.
  42.  
  43. ###############################################################################
  44. #
  45. # Local Settings
  46. #
  47.  
  48. # sysctl location.  If set, it will use sysctl to adjust the kernel parameters.
  49. # If this is set to the empty string (or is unset), the use of sysctl
  50. # is disabled.
  51.  
  52. SYSCTL="/sbin/sysctl -w"
  53.  
  54. # To echo the value directly to the /proc file instead
  55. # SYSCTL=""
  56.  
  57. # IPTables Location - adjust if needed
  58.  
  59. IPT="/sbin/iptables"
  60. IPTS="/sbin/iptables-save"
  61. IPTR="/sbin/iptables-restore"
  62.  
  63. # Internet Interface
  64. INET_IFACE="eth0"
  65.  
  66. # Localhost Interface
  67.  
  68. LO_IFACE="lo"
  69. LO_IP="127.0.0.1"
  70.  
  71. # Save and Restore arguments handled here
  72. if [ "$1" = "save" ]
  73. then
  74.         echo -n "Saving firewall to /etc/sysconfig/iptables ... "
  75.         $IPTS > /etc/sysconfig/iptables
  76.         echo "done"
  77.         exit 0
  78. elif [ "$1" = "restore" ]
  79. then
  80.         echo -n "Restoring firewall from /etc/sysconfig/iptables ... "
  81.         $IPTR < /etc/sysconfig/iptables
  82.         echo "done"
  83.         exit 0
  84. fi
  85.  
  86. ###############################################################################
  87. #
  88. # Load Modules
  89. #
  90.  
  91. echo "Loading kernel modules ..."
  92.  
  93. # You should uncomment the line below and run it the first time just to
  94. # ensure all kernel module dependencies are OK.  There is no need to run
  95. # every time, however.
  96.  
  97. # /sbin/depmod -a
  98.  
  99. # Unless you have kernel module auto-loading disabled, you should not
  100. # need to manually load each of these modules.  Other than ip_tables,
  101. # ip_conntrack, and some of the optional modules, I've left these
  102. # commented by default.  Uncomment if you have any problems or if
  103. # you have disabled module autoload.  Note that some modules must
  104. # be loaded by another kernel module.
  105.  
  106. # core netfilter module
  107. /sbin/modprobe ip_tables
  108.  
  109. # the stateful connection tracking module
  110. /sbin/modprobe ip_conntrack
  111.  
  112. # filter table module
  113. # /sbin/modprobe iptable_filter
  114.  
  115. # mangle table module
  116. # /sbin/modprobe iptable_mangle
  117.  
  118. # nat table module
  119. # /sbin/modprobe iptable_nat
  120.  
  121. # LOG target module
  122. # /sbin/modprobe ipt_LOG
  123.  
  124. # This is used to limit the number of packets per sec/min/hr
  125. # /sbin/modprobe ipt_limit
  126.  
  127. # masquerade target module
  128. # /sbin/modprobe ipt_MASQUERADE
  129.  
  130. # filter using owner as part of the match
  131. # /sbin/modprobe ipt_owner
  132.  
  133. # REJECT target drops the packet and returns an ICMP response.
  134. # The response is configurable.  By default, connection refused.
  135. # /sbin/modprobe ipt_REJECT
  136.  
  137. # This target allows packets to be marked in the mangle table
  138. # /sbin/modprobe ipt_mark
  139.  
  140. # This target affects the TCP MSS
  141. # /sbin/modprobe ipt_tcpmss
  142.  
  143. # This match allows multiple ports instead of a single port or range
  144. # /sbin/modprobe multiport
  145.  
  146. # This match checks against the TCP flags
  147. # /sbin/modprobe ipt_state
  148.  
  149. # This match catches packets with invalid flags
  150. # /sbin/modprobe ipt_unclean
  151.  
  152. # The ftp nat module is required for non-PASV ftp support
  153. /sbin/modprobe ip_nat_ftp
  154.  
  155. # the module for full ftp connection tracking
  156. /sbin/modprobe ip_conntrack_ftp
  157.  
  158. # the module for full irc connection tracking
  159. /sbin/modprobe ip_conntrack_irc
  160.  
  161.  
  162. ###############################################################################
  163. #
  164. # Kernel Parameter Configuration
  165. #
  166. # See http://ipsysctl-tutorial.frozentux.net/chunkyhtml/index.html
  167. # for a detailed tutorial on sysctl and the various settings
  168. # available.
  169.  
  170. # Required to enable IPv4 forwarding.
  171. # Redhat users can try setting FORWARD_IPV4 in /etc/sysconfig/network to true
  172. # Alternatively, it can be set in /etc/sysctl.conf
  173. #if [ "$SYSCTL" = "" ]
  174. #then
  175. #    echo "1" > /proc/sys/net/ipv4/ip_forward
  176. #else
  177. #    $SYSCTL net.ipv4.ip_forward="1"
  178. #fi
  179.  
  180. # This enables dynamic address hacking.
  181. # This may help if you have a dynamic IP address \(e.g. slip, ppp, dhcp\).
  182. #if [ "$SYSCTL" = "" ]
  183. #then
  184. #    echo "1" > /proc/sys/net/ipv4/ip_dynaddr
  185. #else
  186. #    $SYSCTL net.ipv4.ip_dynaddr="1"
  187. #fi
  188.  
  189. # This enables SYN flood protection.
  190. # The SYN cookies activation allows your system to accept an unlimited
  191. # number of TCP connections while still trying to give reasonable
  192. # service during a denial of service attack.
  193. if [ "$SYSCTL" = "" ]
  194. then
  195.     echo "1" > /proc/sys/net/ipv4/tcp_syncookies
  196. else
  197.     $SYSCTL net.ipv4.tcp_syncookies="1"
  198. fi
  199.  
  200. # This enables source validation by reversed path according to RFC1812.
  201. # In other words, did the response packet originate from the same interface
  202. # through which the source packet was sent?  It's recommended for single-homed
  203. # systems and routers on stub networks.  Since those are the configurations
  204. # this firewall is designed to support, I turn it on by default.
  205. # Turn it off if you use multiple NICs connected to the same network.
  206. if [ "$SYSCTL" = "" ]
  207. then
  208.     echo "1" > /proc/sys/net/ipv4/conf/all/rp_filter
  209. else
  210.     $SYSCTL net.ipv4.conf.all.rp_filter="1"
  211. fi
  212.  
  213. # This option allows a subnet to be firewalled with a single IP address.
  214. # It's used to build a DMZ.  Since that's not a focus of this firewall
  215. # script, it's not enabled by default, but is included for reference.
  216. # See: http://www.sjdjweis.com/linux/proxyarp/
  217. #if [ "$SYSCTL" = "" ]
  218. #then
  219. #    echo "1" > /proc/sys/net/ipv4/conf/all/proxy_arp
  220. #else
  221. #    $SYSCTL net.ipv4.conf.all.proxy_arp="1"
  222. #fi
  223.  
  224. # The following kernel settings were suggested by Alex Weeks. Thanks!
  225.  
  226. # This kernel parameter instructs the kernel to ignore all ICMP
  227. # echo requests sent to the broadcast address.  This prevents
  228. # a number of smurfs and similar DoS nasty attacks.
  229. if [ "$SYSCTL" = "" ]
  230. then
  231.     echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
  232. else
  233.     $SYSCTL net.ipv4.icmp_echo_ignore_broadcasts="1"
  234. fi
  235.  
  236. # This option can be used to accept or refuse source routed
  237. # packets.  It is usually on by default, but is generally
  238. # considered a security risk.  This option turns it off.
  239. if [ "$SYSCTL" = "" ]
  240. then
  241.     echo "0" > /proc/sys/net/ipv4/conf/all/accept_source_route
  242. else
  243.     $SYSCTL net.ipv4.conf.all.accept_source_route="0"
  244. fi
  245.  
  246. # This option can disable ICMP redirects.  ICMP redirects
  247. # are generally considered a security risk and shouldn't be
  248. # needed by most systems using this generator.
  249. #if [ "$SYSCTL" = "" ]
  250. #then
  251. #    echo "0" > /proc/sys/net/ipv4/conf/all/accept_redirects
  252. #else
  253. #    $SYSCTL net.ipv4.conf.all.accept_redirects="0"
  254. #fi
  255.  
  256. # However, we'll ensure the secure_redirects option is on instead.
  257. # This option accepts only from gateways in the default gateways list.
  258. if [ "$SYSCTL" = "" ]
  259. then
  260.     echo "1" > /proc/sys/net/ipv4/conf/all/secure_redirects
  261. else
  262.     $SYSCTL net.ipv4.conf.all.secure_redirects="1"
  263. fi
  264.  
  265. # This option logs packets from impossible addresses.
  266. if [ "$SYSCTL" = "" ]
  267. then
  268.     echo "1" > /proc/sys/net/ipv4/conf/all/log_martians
  269. else
  270.     $SYSCTL net.ipv4.conf.all.log_martians="1"
  271. fi
  272.  
  273.  
  274. ###############################################################################
  275. #
  276. # Flush Any Existing Rules or Chains
  277. #
  278.  
  279. echo "Flushing Tables ..."
  280.  
  281. # Reset Default Policies
  282. $IPT -P INPUT ACCEPT
  283. $IPT -P FORWARD ACCEPT
  284. $IPT -P OUTPUT ACCEPT
  285. $IPT -t nat -P PREROUTING ACCEPT
  286. $IPT -t nat -P POSTROUTING ACCEPT
  287. $IPT -t nat -P OUTPUT ACCEPT
  288. $IPT -t mangle -P PREROUTING ACCEPT
  289. $IPT -t mangle -P OUTPUT ACCEPT
  290.  
  291. # Flush all rules
  292. $IPT -F
  293. $IPT -t nat -F
  294. $IPT -t mangle -F
  295.  
  296. # Erase all non-default chains
  297. $IPT -X
  298. $IPT -t nat -X
  299. $IPT -t mangle -X
  300.  
  301. if [ "$1" = "stop" ]
  302. then
  303.         echo "Firewall completely flushed!  Now running with no firewall."
  304.         exit 0
  305. fi
  306.  
  307. ###############################################################################
  308. #
  309. # Rules Configuration
  310. #
  311.  
  312. ###############################################################################
  313. #
  314. # Filter Table
  315. #
  316. ###############################################################################
  317.  
  318. # Set Policies
  319.  
  320. $IPT -P INPUT DROP
  321. $IPT -P OUTPUT DROP
  322. $IPT -P FORWARD DROP
  323.  
  324. ###############################################################################
  325. #
  326. # User-Specified Chains
  327. #
  328. # Create user chains to reduce the number of rules each packet
  329. # must traverse.
  330.  
  331. echo "Create and populate custom rule chains ..."
  332.  
  333. # Create a chain to filter INVALID packets
  334.  
  335. $IPT -N bad_packets
  336.  
  337. # Create another chain to filter bad tcp packets
  338.  
  339. $IPT -N bad_tcp_packets
  340.  
  341. # Create separate chains for icmp, tcp (incoming and outgoing),
  342. # and incoming udp packets.
  343.  
  344. $IPT -N icmp_packets
  345.  
  346. # Used for UDP packets inbound from the Internet
  347. $IPT -N udp_inbound
  348.  
  349. # Used to block outbound UDP services from internal network
  350. # Default to allow all
  351. $IPT -N udp_outbound
  352.  
  353. # Used to allow inbound services if desired
  354. # Default fail except for established sessions
  355. $IPT -N tcp_inbound
  356.  
  357. # Used to block outbound services from internal network
  358. # Default to allow all
  359. $IPT -N tcp_outbound
  360.  
  361. ###############################################################################
  362. #
  363. # Populate User Chains
  364. #
  365.  
  366. # bad_packets chain
  367. #
  368.  
  369. # Drop INVALID packets immediately
  370. $IPT -A bad_packets -p ALL -m state --state INVALID -j LOG \
  371.     --log-prefix "Invalid packet: "
  372.  
  373. $IPT -A bad_packets -p ALL -m state --state INVALID -j DROP
  374.  
  375. # Then check the tcp packets for additional problems
  376. $IPT -A bad_packets -p tcp -j bad_tcp_packets
  377.  
  378. # All good, so return
  379. $IPT -A bad_packets -p ALL -j RETURN
  380.  
  381. # bad_tcp_packets chain
  382. #
  383. # All tcp packets will traverse this chain.
  384. # Every new connection attempt should begin with
  385. # a syn packet.  If it doesn't, it is likely a
  386. # port scan.  This drops packets in state
  387. # NEW that are not flagged as syn packets.
  388.  
  389.  
  390. $IPT -A bad_tcp_packets -p tcp ! --syn -m state --state NEW -j LOG \
  391.     --log-prefix "New not syn: "
  392. $IPT -A bad_tcp_packets -p tcp ! --syn -m state --state NEW -j DROP
  393.  
  394. $IPT -A bad_tcp_packets -p tcp --tcp-flags ALL NONE -j LOG \
  395.     --log-prefix "Stealth scan: "
  396. $IPT -A bad_tcp_packets -p tcp --tcp-flags ALL NONE -j DROP
  397.  
  398. $IPT -A bad_tcp_packets -p tcp --tcp-flags ALL ALL -j LOG \
  399.     --log-prefix "Stealth scan: "
  400. $IPT -A bad_tcp_packets -p tcp --tcp-flags ALL ALL -j DROP
  401.  
  402. $IPT -A bad_tcp_packets -p tcp --tcp-flags ALL FIN,URG,PSH -j LOG \
  403.     --log-prefix "Stealth scan: "
  404. $IPT -A bad_tcp_packets -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
  405.  
  406. $IPT -A bad_tcp_packets -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j LOG \
  407.     --log-prefix "Stealth scan: "
  408. $IPT -A bad_tcp_packets -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
  409.  
  410. $IPT -A bad_tcp_packets -p tcp --tcp-flags SYN,RST SYN,RST -j LOG \
  411.     --log-prefix "Stealth scan: "
  412. $IPT -A bad_tcp_packets -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
  413.  
  414. $IPT -A bad_tcp_packets -p tcp --tcp-flags SYN,FIN SYN,FIN -j LOG \
  415.     --log-prefix "Stealth scan: "
  416. $IPT -A bad_tcp_packets -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
  417.  
  418. # All good, so return
  419. $IPT -A bad_tcp_packets -p tcp -j RETURN
  420.  
  421. # icmp_packets chain
  422. #
  423. # This chain is for inbound (from the Internet) icmp packets only.
  424. # Type 8 (Echo Request) is not accepted by default
  425. # Enable it if you want remote hosts to be able to reach you.
  426. # 11 (Time Exceeded) is the only one accepted
  427. # that would not already be covered by the established
  428. # connection rule.  Applied to INPUT on the external interface.
  429. #
  430. # See: http://www.ee.siue.edu/~rwalden/networking/icmp.html
  431. # for more info on ICMP types.
  432. #
  433. # Note that the stateful settings allow replies to ICMP packets.
  434. # These rules allow new packets of the specified types.
  435.  
  436. # ICMP packets should fit in a Layer 2 frame, thus they should
  437. # never be fragmented.  Fragmented ICMP packets are a typical sign
  438. # of a denial of service attack.
  439. $IPT -A icmp_packets --fragment -p ICMP -j LOG \
  440.     --log-prefix "ICMP Fragment: "
  441. $IPT -A icmp_packets --fragment -p ICMP -j DROP
  442.  
  443. # Echo - uncomment to allow your system to be pinged.
  444. # Uncomment the LOG command if you also want to log PING attempts
  445. #
  446. # $IPT -A icmp_packets -p ICMP -s 0/0 --icmp-type 8 -j LOG \
  447. #    --log-prefix "Ping detected: "
  448. # $IPT -A icmp_packets -p ICMP -s 0/0 --icmp-type 8 -j ACCEPT
  449.  
  450. # By default, however, drop pings without logging. Blaster
  451. # and other worms have infected systems blasting pings.
  452. # Comment the line below if you want pings logged, but it
  453. # will likely fill your logs.
  454. $IPT -A icmp_packets -p ICMP -s 0/0 --icmp-type 8 -j DROP
  455.  
  456. # Time Exceeded
  457. $IPT -A icmp_packets -p ICMP -s 0/0 --icmp-type 11 -j ACCEPT
  458.  
  459. # Not matched, so return so it will be logged
  460. $IPT -A icmp_packets -p ICMP -j RETURN
  461.  
  462. # TCP & UDP
  463. # Identify ports at:
  464. #    http://www.chebucto.ns.ca/~rakerman/port-table.html
  465. #    http://www.iana.org/assignments/port-numbers
  466.  
  467. # udp_inbound chain
  468. #
  469. # This chain describes the inbound UDP packets it will accept.
  470. # It's applied to INPUT on the external or Internet interface.
  471. # Note that the stateful settings allow replies.
  472. # These rules are for new requests.
  473. # It drops netbios packets (windows) immediately without logging.
  474.  
  475. # Drop netbios calls
  476. # Please note that these rules do not really change the way the firewall
  477. # treats netbios connections.  Connections from the localhost and
  478. # internal interface (if one exists) are accepted by default.
  479. # Responses from the Internet to requests initiated by or through
  480. # the firewall are also accepted by default.  To get here, the
  481. # packets would have to be part of a new request received by the
  482. # Internet interface.  You would have to manually add rules to
  483. # accept these.  I added these rules because some network connections,
  484. # such as those via cable modems, tend to be filled with noise from
  485. # unprotected Windows machines.  These rules drop those packets
  486. # quickly and without logging them.  This prevents them from traversing
  487. # the whole chain and keeps the log from getting cluttered with
  488. # chatter from Windows systems.
  489. $IPT -A udp_inbound -p UDP -s 0/0 --destination-port 137 -j DROP
  490. $IPT -A udp_inbound -p UDP -s 0/0 --destination-port 138 -j DROP
  491.  
  492. # Dynamic Address
  493. # If DHCP, the initial request is a broadcast. The response
  494. # doesn't exactly match the outbound packet.  This explicitly
  495. # allow the DHCP ports to alleviate this problem.
  496. # If you receive your dynamic address by a different means, you
  497. # can probably comment this line.
  498. $IPT -A udp_inbound -p UDP -s 0/0 --source-port 67 --destination-port 68 \
  499.      -j ACCEPT
  500.  
  501.  
  502. # Not matched, so return for logging
  503. $IPT -A udp_inbound -p UDP -j RETURN
  504.  
  505. # udp_outbound chain
  506. #
  507. # This chain is used with a private network to prevent forwarding for
  508. # UDP requests on specific protocols.  Applied to the FORWARD rule from
  509. # the internal network.  Ends with an ACCEPT
  510.  
  511.  
  512. # No match, so ACCEPT
  513. $IPT -A udp_outbound -p UDP -s 0/0 -j ACCEPT
  514.  
  515. # tcp_inbound chain
  516. #
  517. # This chain is used to allow inbound connections to the
  518. # system/gateway.  Use with care.  It defaults to none.
  519. # It's applied on INPUT from the external or Internet interface.
  520.  
  521.  
  522. # Not matched, so return so it will be logged
  523. $IPT -A tcp_inbound -p TCP -j RETURN
  524.  
  525. # tcp_outbound chain
  526. #
  527. # This chain is used with a private network to prevent forwarding for
  528. # requests on specific protocols.  Applied to the FORWARD rule from
  529. # the internal network.  Ends with an ACCEPT
  530.  
  531.  
  532. # No match, so ACCEPT
  533. $IPT -A tcp_outbound -p TCP -s 0/0 -j ACCEPT
  534.  
  535. ###############################################################################
  536. #
  537. # INPUT Chain
  538. #
  539.  
  540. echo "Process INPUT chain ..."
  541.  
  542. # Allow all on localhost interface
  543. $IPT -A INPUT -p ALL -i $LO_IFACE -j ACCEPT
  544.  
  545. # Drop bad packets
  546. $IPT -A INPUT -p ALL -j bad_packets
  547.  
  548. # DOCSIS compliant cable modems
  549. # Some DOCSIS compliant cable modems send IGMP multicasts to find
  550. # connected PCs.  The multicast packets have the destination address
  551. # 224.0.0.1.  You can accept them.  If you choose to do so,
  552. # Uncomment the rule to ACCEPT them and comment the rule to DROP
  553. # them  The firewall will drop them here by default to avoid
  554. # cluttering the log.  The firewall will drop all multicasts
  555. # to the entire subnet (224.0.0.1) by default.  To only affect
  556. # IGMP multicasts, change '-p ALL' to '-p 2'.  Of course,
  557. # if they aren't accepted elsewhere, it will only ensure that
  558. # multicasts on other protocols are logged.
  559. # Drop them without logging.
  560. $IPT -A INPUT -p ALL -d 224.0.0.1 -j DROP
  561. # The rule to accept the packets.
  562. # $IPT -A INPUT -p ALL -d 224.0.0.1 -j ACCEPT
  563.  
  564.  
  565. # Inbound Internet Packet Rules
  566.  
  567. # Accept Established Connections
  568. $IPT -A INPUT -p ALL -i $INET_IFACE -m state --state ESTABLISHED,RELATED \
  569.      -j ACCEPT
  570.  
  571. # Route the rest to the appropriate user chain
  572. $IPT -A INPUT -p TCP -i $INET_IFACE -j tcp_inbound
  573. $IPT -A INPUT -p UDP -i $INET_IFACE -j udp_inbound
  574. $IPT -A INPUT -p ICMP -i $INET_IFACE -j icmp_packets
  575.  
  576. # Drop without logging broadcasts that get this far.
  577. # Cuts down on log clutter.
  578. # Comment this line if testing new rules that impact
  579. # broadcast protocols.
  580. $IPT -A INPUT -m pkttype --pkt-type broadcast -j DROP
  581.  
  582. # Log packets that still don't match
  583. $IPT -A INPUT -m limit --limit 3/minute --limit-burst 3 -j LOG \
  584.     --log-prefix "INPUT packet died: "
  585.  
  586. ###############################################################################
  587. #
  588. # FORWARD Chain
  589. #
  590.  
  591. echo "Process FORWARD chain ..."
  592.  
  593. # Used if forwarding for a private network
  594.  
  595.  
  596. ###############################################################################
  597. #
  598. # OUTPUT Chain
  599. #
  600.  
  601. echo "Process OUTPUT chain ..."
  602.  
  603. # Generally trust the firewall on output
  604.  
  605. # However, invalid icmp packets need to be dropped
  606. # to prevent a possible exploit.
  607. $IPT -A OUTPUT -m state -p icmp --state INVALID -j DROP
  608.  
  609. # Localhost
  610. $IPT -A OUTPUT -p ALL -s $LO_IP -j ACCEPT
  611. $IPT -A OUTPUT -p ALL -o $LO_IFACE -j ACCEPT
  612.  
  613. # To internet
  614. $IPT -A OUTPUT -p ALL -o $INET_IFACE -j ACCEPT
  615.  
  616. # Log packets that still don't match
  617. $IPT -A OUTPUT -m limit --limit 3/minute --limit-burst 3 -j LOG \
  618.     --log-prefix "OUTPUT packet died: "
  619.  
  620. ###############################################################################
  621. #
  622. # nat table
  623. #
  624. ###############################################################################
  625.  
  626. # The nat table is where network address translation occurs if there
  627. # is a private network.  If the gateway is connected to the Internet
  628. # with a static IP, snat is used.  If the gateway has a dynamic address,
  629. # masquerade must be used instead.  There is more overhead associated
  630. # with masquerade, so snat is better when it can be used.
  631. # The nat table has a builtin chain, PREROUTING, for dnat and redirects.
  632. # Another, POSTROUTING, handles snat and masquerade.
  633.  
  634. echo "Load rules for nat table ..."
  635.  
  636. ###############################################################################
  637. #
  638. # PREROUTING chain
  639. #
  640.  
  641.  
  642. ###############################################################################
  643. #
  644. # POSTROUTING chain
  645. #
  646.  
  647.  
  648. ###############################################################################
  649. #
  650. # mangle table
  651. #
  652. ###############################################################################
  653.  
  654. # The mangle table is used to alter packets.  It can alter or mangle them in
  655. # several ways.  For the purposes of this generator, we only use its ability
  656. # to alter the TTL in packets.  However, it can be used to set netfilter
  657. # mark values on specific packets.  Those marks could then be used in another
  658. # table like filter, to limit activities associated with a specific host, for
  659. # instance.  The TOS target can be used to set the Type of Service field in
  660. # the IP header.  Note that the TTL target might not be included in the
  661. # distribution on your system.  If it is not and you require it, you will
  662. # have to add it.  That may require that you build from source.
  663.  
  664. echo "Load rules for mangle table ..."
  665.  
  666.  

Reply to "Untitled"

Here you can reply to the paste above