Nytro Posted April 19, 2014 Report Posted April 19, 2014 ABSTRACTReaders, there are numerous reasons ... It is well known that the Internet is an unmanaged an decentralized network, running under a set of protocols, which are not designed to ensure the integrity and confidentiality of information and access controls.There are several ways to breach a network, but these ways do nothing more than take advantage of flaws within network protocols and services.CONCEPTSIPTABLES is an editing tool for packet filtering, with it you can analyze the header and make decisions about the destinations of these packets, it is not the only existing solution to control this filtering. We still have the old ipfwadm and ipchains, etc.It is important to note that in Gnu / Linux, packet filtering is built into the kernel. Why not configure your installation in accordance with this article, since most distributions come with it enabled as a module or compiled directly into the kernel.STEP BY STEPcase "$1" instart)Clearing Rulesiptables -t filter -Fiptables -t filter -XTips [ICMP ECHO-REQUEST] messages sent to broadcast or multicastecho 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcastsProtection against ICMP redirect requestecho 0 > /proc/sys/net/ipv4/conf/all/accept_redirectsDo not send messages, ICMP redirected.echo 0 > /proc/sys/net/ipv4/conf/all/send_redirects(Ping) ICMP iptables -t filter -A INPUT -p icmp -j ACCEPTiptables -t filter -A OUTPUT -p icmp -j ACCEPTPackages logs with nonexistent addresses (due to wrong routes) on your networkecho 1 > /proc/sys/net/ipv4/conf/all/log_martiansEnabling forwarding packets (required for NAT)echo "1" >/proc/sys/net/ipv4/ip_forwardSSH acceptediptables -t filter -A INPUT -p tcp --dport 22 -j ACCEPTDo not break established connectionsiptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPTiptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPTBlock all connections by defaultiptables -t filter -P INPUT DROPiptables -t filter -P FORWARD DROPiptables -t filter -P OUTPUT DROPIP spoofing protectionecho "1" > /proc/sys/net/ipv4/conf/default/rp_filterecho - Subindo proteção contra ip spoofing : [OK]Disable sending the IPV4echo 0 > /proc/sys/net/ipv4/ip_forwardSYN-Flood Protectioniptables -N syn-floodiptables -A syn-flood -m limit --limit 10/second --limit-burst 50 -j RETURNiptables -A syn-flood -j LOG --log-prefix "SYN FLOOD: "iptables -A syn-flood -j DROP# Loopbackiptables -t filter -A INPUT -i lo -j ACCEPTiptables -t filter -A OUTPUT -o lo -j ACCEPTTips connections scansiptables -A INPUT -m recent --name scan --update --seconds 600 --rttl --hitcount 3 -j DROPiptables -A INPUT -m recent --name scan --update --seconds 600 --rttl --hitcount 3 -j LOG --log-level info --log-prefix "Scan recent"Tips SYN packets invalidiptables -A INPUT -p tcp --tcp-flags ALL ACK,RST,SYN,FIN -j DROPiptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROPiptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROPiptables -A INPUT -p tcp --tcp-flags ALL ACK,RST,SYN,FIN -j LOG --log-level info --log-prefix "Packages SYN Detected"iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j LOG --log-level info --log-prefix "Packages SYN Detected"iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j LOG --log-level info --log-prefix "Packages SYN Detected"# Tips SYN packets invalidiptables -A OUTPUT -p tcp --tcp-flags ALL ACK,RST,SYN,FIN -j DROPiptables -A OUTPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROPiptables -A OUTPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROPiptables -A INPUT -p tcp --tcp-flags ALL ACK,RST,SYN,FIN -j LOG --log-level info --log-prefix "Packages SYN Detected"iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j LOG --log-level info --log-prefix "Packages SYN Detected"iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j LOG --log-level info --log-prefix "Packages SYN Detected"Certifies that new packets are SYN, otherwise they Tipsiptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROPDiscard packets with fragments of entry. Attack that can cause data lossiptables -A INPUT -f -j DROPiptables -A INPUT -f -j LOG --log-level info --log-prefix "Packages fragmented entries"Tips malformed XMAS packetsiptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROPiptables -A INPUT -p tcp --tcp-flags ALL ALL -j LOG --log-level info --log-prefix "malformed XMAS packets"DNS In/Outiptables -t filter -A OUTPUT -p tcp --dport 53 -j ACCEPTiptables -t filter -A OUTPUT -p udp --dport 53 -j ACCEPTiptables -t filter -A INPUT -p tcp --dport 53 -j ACCEPTiptables -t filter -A INPUT -p udp --dport 53 -j ACCEPTNTP Outiptables -t filter -A OUTPUT -p udp --dport 123 -j ACCEPTWHOIS Outiptables -t filter -A OUTPUT -p tcp --dport 43 -j ACCEPTFTP Outiptables -t filter -A OUTPUT -p tcp --dport 20:21 -j ACCEPTiptables -t filter -A OUTPUT -p tcp --dport 30000:50000 -j ACCEPTFTP Iniptables -t filter -A INPUT -p tcp --dport 20:21 -j ACCEPTiptables -t filter -A INPUT -p tcp --dport 30000:50000 -j ACCEPTiptables -t filter -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPTHTTP + HTTPS Outiptables -t filter -A OUTPUT -p tcp --dport 80 -j ACCEPTiptables -t filter -A OUTPUT -p tcp --dport 443 -j ACCEPTHTTP + HTTPS Iniptables -t filter -A INPUT -p tcp --dport 80 -j ACCEPTiptables -t filter -A INPUT -p tcp --dport 443 -j ACCEPTMail SMTP:25iptables -t filter -A INPUT -p tcp --dport 25 -j ACCEPTiptables -t filter -A OUTPUT -p tcp --dport 25 -j ACCEPTMail POP3:110iptables -t filter -A INPUT -p tcp --dport 110 -j ACCEPTiptables -t filter -A OUTPUT -p tcp --dport 110 -j ACCEPTMail IMAP:143iptables -t filter -A INPUT -p tcp --dport 143 -j ACCEPTiptables -t filter -A OUTPUT -p tcp --dport 143 -j ACCEPT# Reverseiptables -t filter -A INPUT -p tcp --dport 77 -j ACCEPTiptables -t filter -A OUTPUT -p tcp --dport 77 -j ACCEPTMSFiptables -t filter -A INPUT -p tcp --dport 7337 -j ACCEPTiptables -t filter -A OUTPUT -p tcp --dport 7337 -j ACCEPT#######################################WEB Management Firewalltouch /var/log/firewallchmod +x /var/log/firewall/var/log/firewall -A INPUT -p icmp -m limit --limit 1/s -j LOG --log-level info --log-prefix "ICMP Dropped "/var/log/firewall -A INPUT -p tcp -m limit --limit 1/s -j LOG --log-level info --log-prefix "TCP Dropped "/var/log/firewall -A INPUT -p udp -m limit --limit 1/s -j LOG --log-level info --log-prefix "UDP Dropped "/var/log/firewall -A INPUT -f -m limit --limit 1/s -j LOG --log-level warning --log-prefix "FRAGMENT Dropped "/var/log/firewall -A INPUT -m limit --limit 1/minute --limit-burst 3 -j LOG --log-level DEBUG --log-prefix "IPT INPUT packet died: "/var/log/firewall -A INPUT -m limit --limit 3/minute --limit-burst 3 -j LOG --log-level DEBUG --log-prefix "IPT INPUT packet died: "exit 0;;stop)echo "turning off the firewall "iptables -P INPUT ACCEPTiptables -P OUTPUT ACCEPTiptables -t filter -Fexit 0;;restart)/etc/init.d/firewall stop/etc/init.d/firewall start;;echo "Use: /etc/init.d/firewall {start|stop|restart}"exit 1;;esacLogs available: /var/log/firewallCOMMANDS TO MONITOR LOGS: tail -f /var/log/messagesSave: /etc/init.d/firewallCONCLUSIONGentlemen, I hope to help you in configuring your network security and remind you to choose only the best options available.Allow me to add a few Advantages of using your firewall. Be sure to Block unknown and unauthorized connections. You can specify what types of network protocols and services to be provided and you may control the packets from any untrusted services. Your firewall also allows blocking websites with URL filters, access control, access logs for reports by user, protecting the corporate network through proxies, and Automatic Address Conversion (NAT). Control services that can either be executed or not, on the network allowing for high performance in their duties with easy administration and reliability.Sursa: A Beginners Guide To Using IPTables | Learn How To Hack - Ethical Hacking and security tips Quote