06-12-2015
I don't understand the logic why it was not working if i put after reject.
---------- Post updated at 12:19 PM ---------- Previous update was at 12:18 PM ----------
I want to add some more attack tables where i need to add. all are DROP
Quote:
# Reject spoofed packets
-A INPUT -s 10.0.0.0/8 -j DROP
-A INPUT -s 169.254.0.0/16 -j DROP
-A INPUT -s 172.16.0.0/12 -j DROP
-A INPUT -s 127.0.0.0/8 -j DROP
-A INPUT -s 224.0.0.0/4 -j DROP
-A INPUT -d 224.0.0.0/4 -j DROP
-A INPUT -s 240.0.0.0/5 -j DROP
-A INPUT -d 240.0.0.0/5 -j DROP
-A INPUT -s 0.0.0.0/8 -j DROP
-A INPUT -d 0.0.0.0/8 -j DROP
-A INPUT -d 239.255.255.0/24 -j DROP
-A INPUT -d 255.255.255.255 -j DROP
# NULL packets
-A INPUT -p tcp --tcp-flags ALL NONE -j DROP
# Syn-flood attack
-A INPUT -p tcp ! --syn -m state --state NEW -j DROP
# XMAS packets
-A INPUT -p tcp --tcp-flags ALL ALL -j DROP
#Force Fragments packets check
-A INPUT -f -j DROP
# Stop smurf attacks
-A INPUT -p icmp -m icmp --icmp-type address-mask-request -j DROP
-A INPUT -p icmp -m icmp --icmp-type timestamp-request -j DROP
-A INPUT -p icmp -m icmp -j DROP
# Drop all invalid packets
-A INPUT -m state --state INVALID -j DROP
-A FORWARD -m state --state INVALID -j DROP
-A OUTPUT -m state --state INVALID -j DROP
# Drop excessive RST packets to avoid smurf attacks
-A INPUT -p tcp -m tcp --tcp-flags RST RST -m limit --limit 2/second --limit-burst 2 -j ACCEPT
# Attempt to block portscans
# Anyone who tried to portscan us is locked out for an entire day.
-A INPUT -m recent --name portscan --rcheck --seconds 86400 -j DROP
-A FORWARD -m recent --name portscan --rcheck --seconds 86400 -j DROP
# Once the day has passed, remove them from the portscan list
-A INPUT -m recent --name portscan --remove
-A FORWARD -m recent --name portscan --remove
# These rules add scanners to the portscan list, and log the attempt.
-A INPUT -p tcp -m tcp --dport 139 -m recent --name portscan --set -j LOG --log-prefix "Portscan:"
-A INPUT -p tcp -m tcp --dport 139 -m recent --name portscan --set -j DROP
-A FORWARD -p tcp -m tcp --dport 139 -m recent --name portscan --set -j LOG --log-prefix "Portscan:"
-A FORWARD -p tcp -m tcp --dport 139 -m recent --name portscan --set -j DROP
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I've been googling for a while now, trying to forward port 3000 to port 80....
In the past I used to DLink router to forward port 3000 to 80. I recently finished (well, is it ever done anyhow?) setting up my linux box and got it acting as a router.
I want to continue to run Apache on port 80... (1 Reply)
Discussion started by: meeps
1 Replies
2. Fedora
Hi..
Anyone can help me..I have setup my linux fedora server and i want to restrict access to my server.Basically i control using iptables.I'm not sure how to write an iptables rules to control drop all connection to port 8080 and allow only certain ip can access the instance on port 8080 example... (0 Replies)
Discussion started by: netxus
0 Replies
3. UNIX for Advanced & Expert Users
I would like to copy data flow (not redirect!!!) from 1567 port
to another 1194 port on same computer. The 1567 Port already binded by Scream program (it is bisy). Is it possible to do it by iptables or for it nesessary another programs? Can you help me in the decision of this question? (1 Reply)
Discussion started by: yanat
1 Replies
4. UNIX for Advanced & Expert Users
Hi To All,
I want to Route my web application to Mysql Database through a proxy server.so for this which approach should i use
1)iptables
2)squid
if Iptables how can i make this worked .this is the ip network i'm having
web application---------Proxy server-----------------Mysql Database... (0 Replies)
Discussion started by: kgrvamsi
0 Replies
5. Debian
Hello, the Nat and the forward worked on my debian server up to the reboot of machines.
The following rules*:
/sbin/iptables -t nat -A PREROUTING -p tcp -i eth2 -d xxx.xxx.xxx.xxx --dport 29070 -j DNAT --to-destination 10.0.1.7:29070
/sbin/iptables -A FORWARD -p tcp -i eth2 -o eth0 -d... (0 Replies)
Discussion started by: titoms
0 Replies
6. Red Hat
Hi,
I have a newly built RHEL5 OS that is unable to talk to the DNS server. I am unable to telnet resolv.conf entry over port 53 but apparently this port has been opened.
# telnet 209.212.96.1 53
and.....
# dig www.google.com
; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5_4.2 <<>>... (9 Replies)
Discussion started by: Duffs22
9 Replies
7. Red Hat
Hi,
What iptables command do I need to run in order to open up the following port for incomming traffic on the following server:
# telnet 127.0.0.1 1521
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host: Connection... (3 Replies)
Discussion started by: Duffs22
3 Replies
8. IP Networking
Hi,
On my linux server I have 2 routes:
Code:
nexthop via 123.201.254.5 dev eth0 weight 38 nexthop via 111.93.155.149 dev eth2 weight 36
I have a iptable rule like :
iptables -t nat -A PREROUTING -p tcp -i eth0 -d... (5 Replies)
Discussion started by: ashokvpp
5 Replies
9. UNIX for Dummies Questions & Answers
I want to limit all *outbound* traffic on eth0 (or all *.*) on port 25 to a specific (allowed) range...
I.E.
192.168.1.5 (local ip) tries to connect to 1.2.3.4:25 (outside real world ip)
It can proceed because 1.2.3.0/24 is the allowed range
Now, 192.168.1.5 (local ip) tries to connect to... (1 Reply)
Discussion started by: holyearth
1 Replies
10. Red Hat
Hello All,
I would like to ask you very kindly with /etc/sysconfig/iptables file
I have to setup port forwarding on RHEL6 router. Users from public network must be able to ssh to servers in private network behind RHEL6 router. Problem is that servers in private network must be isolated.
My... (2 Replies)
Discussion started by: oidipus
2 Replies
LEARN ABOUT DEBIAN
lockout
LOCKOUT(1) lockout LOCKOUT(1)
NAME
lockout - avoid slacking and impose productivity and discipline on yourself
WARNING
This program is VERY DANGEROUS. If it fails, you may end up not knowing the root password to your own computer (in which case you need to
boot into single-user mode). There are no known reports of this actually happening, but we don't know how stupid you are. Also, you
should probably not run this on a multi-user system.
SYNOPSIS
lockout lock HhMm | Hh | Mm
lockout lock HH:MM
lockout lock HH:MMam | HH:MMpm
lockout lock HHam | HHpm
lockout lock
lockout unlock [force]
lockout status
DESCRIPTION
Lockout is a tool that imposes discipline on you so that you get some work done. For example, lockout can be used to install a firewall
that does not let you browse the Web. Lockout changes the root password for a specified duration; this prevents you from secretly ripping
down the firewall and then browsing the Web anyway. In case of an emergency, you can reboot your computer to undo the effects of lockout
and to restore the original root password.
Obviously, lockout lock and lockout unlock can only be run by root. lockout status can be run by any user.
lockout without any parameters shows a brief help message.
lockout lock takes one optional parameter. If no parameter is given, you are dropped in interactive mode and asked for the duration of the
lock or the time at which the lock should be lifted. You can also supply this as a parameter on the command line. Lockout understands
various time formats. You can specify a delay, e.g., 3h (3 hours), 1h30m (1 hour and 30 minutes), or 90m (1 hour and 30 minutes), or you
can specify absolute time, e.g., 2pm, 2:30am, 15:30, etc. You will be asked to confirm the time at which lockout will unlock your system.
If you type "yes", lockout executes /etc/lockout/lock.sh and changes the root password to something completely random. /etc/lock-
out/lock.sh is a shell script that you write. It takes measures to make sure you stop slacking. For example, it could install a firewall
that prevents outgoing connections to port 80. See the "EXAMPLES" section below.
lockout unlock takes an optional force parameter. Without any parameters, lockout lock will check whether it is time to unlock the system
and, if so, executes /etc/lockout/unlock.sh, which is a shell script that you write. It should undo the effects of /etc/lockout/lock.sh,
executed when the system was locked. If you pass the force parameter to lockout unlock, lockout will forcibly unlock your system, whether
it was really time for that or not. lockout unlock should be called every minute by cron. See "CONFIGURATION".
lockout status will print out the time at which the system is going to be unlocked.
CONFIGURATION
/etc/cron.d/lockout must contain the following two entries:
*/1 * * * * root /usr/bin/lockout unlock >/dev/null 2>&1
@reboot root /usr/bin/lockout unlock force >/dev/null 2>&1
The examples that follow assume you are using sudo(8) and you have a file, /etc/lockout/sudoers.normal which is the normal /etc/sudoers
file, and /etc/lockout/sudoers.lock, which is the /etc/sudoers file when lockout locks your computer. This example also assumes you are
using iptables(8). /var/lib/iptables/active should contain your default firewall rules, and /var/lib/iptables/work should contain the
firewall rules that enforce discipline. See below for an example.
/etc/lock/lock.sh imposes discipline. For example:
#!/bin/sh
/etc/init.d/iptables load work
cp /etc/lockout/sudoers.lock /etc/sudoers
/etc/init.d/sudo stop
/etc/init.d/sudo start
/etc/lock/unlock.sh undoes these effects. For example:
#!/bin/sh
/etc/init.d/iptables restart
cp /etc/lockout/sudoers.normal /etc/sudoers
/etc/init.d/sudo stop
/etc/init.d/sudo start
Your /var/lib/iptables/work may look something like this:
*filter
:INPUT ACCEPT [1047:99548]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [1104:120792]
# allow incoming packets from localhost, ntp,
# and existing connections
-A INPUT -i lo -j ACCEPT
-A INPUT -p udp -m udp --source-port ntp -m state --state ESTABLISHED -j ACCEPT
-A INPUT -m state --state ESTABLISHED -j ACCEPT
-A INPUT -p tcp -j DROP
-A INPUT -p udp -j DROP
# allow outgoing connections for email and DNS
-A OUTPUT -d 127.0.0.1/8 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport smtp -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport domain -j ACCEPT
-A OUTPUT -p udp -m udp --dport domain -j ACCEPT
-A OUTPUT -j DROP
COMMIT
EXAMPLES
lockout lock 2h30m [locks out for 2h and 30m]
lockout lock 90m [locks out for 1h and 30m]
lockout lock 3pm [locks out until 3pm]
lockout lock 3:20am [locks out until 3:20am]
lockout lock 15:20 [locks out until 3:20pm]
lockout status [shows when the system is going to be unlocked]
FILES
/etc/lockout/lock.sh: executed when running lockout lock
/etc/lockout/unlock.sh: executed when running lockout unlock
SEE ALSO
usermod(8), iptables(8), passwd(1), cron(8), crontab(1)
BUGS
Arguably, a program that changes the root password to something random with the possibility of never recovering the original password might
be considered a bug by itself. Other than that, no known bugs.
AUTHOR
Thomer M. Gil, http://thomer.com/lockout/
lockout 2004-09-08 LOCKOUT(1)