services for predetermined IP addresses
Hello,
As I see increased scans on my IP address, I want to limit access to only predetermined IP address ranges for certain services - Is the following the correct way to do this?
<snip>
# (Part A) Rules for incoming packets from Internet # Packets for established connections iptables -A INPUT -p ALL -d $ETH0_IP -m state --state ESTABLISHED,RELATED -j ACCEPT
# (Part B) TCP Rules
iptables -A INPUT -p TCP -i eth0 -s 123.45.1.1 --destination-port 21 -j okay # userA iptables -A INPUT -p TCP -i eth0 -s 123.45.0/16 --destination-port 22 -j okay #users A - Z </snip>
So I understand -
ONLY User A can ftp, and all those in 123.45. can ssh , BUT no-one else on the Internet can request services ?
Thanks in advance
Kate
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
Quoted 7 lines · kate
Hello,
As I see increased scans on my IP address, I want to limit access to only predetermined IP address ranges for certain services - Is the following the correct way to do this?
Quoted 5 lines
<snip>
# (Part A) Rules for incoming packets from Internet # Packets for established connections iptables -A INPUT -p ALL -d $ETH0_IP -m state --state ESTABLISHED,RELATED -j ACCEPT
stylistic note: the "-p ALL" is kinda unnecessary...
Quoted 5 lines
# (Part B) TCP Rules
iptables -A INPUT -p TCP -i eth0 -s 123.45.1.1 --destination-port 21 -j okay # userA iptables -A INPUT -p TCP -i eth0 -s 123.45.0/16 --destination-port 22 -j okay #users A - Z
i think you're missing a "0" there: 123.45.0/16 should really be 123.45.0.0/16.
Quoted 6 lines
</snip>
So I understand -
ONLY User A can ftp, and all those in 123.45. can ssh , BUT no-one else on the Internet can request services ?
yes--as along as somewhere further down the chain you hit a drop-all rule of some sort...
-j
Signature · 1 line
Jason Opperisano <[email protected]>
Quoted 37 lines · --- Jason Opperisano
Quoted 3 lines · kate
Hello,
As I see increased scans on my IP address, I want
to
Quoted 1 line
limit access to only predetermined IP address
ranges
Quoted 1 line
for certain services - Is the following the
correct
Quoted 4 lines
way to do this?
<snip>
# (Part A) Rules for incoming packets fromInternet
Quoted 2 lines
# Packets for established connections
iptables -A INPUT -p ALL -d $ETH0_IP -m state--state
Quoted 1 line
ESTABLISHED,RELATED -j ACCEPT
stylistic note: the "-p ALL" is kinda
unnecessary...Quoted 5 lines
# (Part B) TCP Rules
iptables -A INPUT -p TCP -i eth0 -s 123.45.1.1
--destination-port 21 -j okay # userA
iptables -A INPUT -p TCP -i eth0 -s 123.45.0/16
--destination-port 22 -j okay #users A - Zi think you're missing a "0" there: 123.45.0/16
should really be
123.45.0.0/16.Quoted 4 lines
</snip>
So I understand -
ONLY User A can ftp, and all those in 123.45. can
Quoted 8 lines
ssh
Quoted 1 line
, BUT no-one else on the Internet can request
services
Quoted 1 line
?
yes--as along as somewhere further down the chain
you hit a drop-all
rule of some sort...
Yes, I see that now...
# (Part B) TCP Rules
iptables -A INPUT -p TCP -i eth0 -s 123.45.1.1
--destination-port 21 -j okay # userA
iptables -A INPUT -p TCP -i eth0 -s 123.45.0.0/16
--destination-port 22 -j okay #users A - Z
so the drop-all would be..?
iptables -A INPUT -p TCP -i eth0 -s 0/0 -j DROP
or did I just invent my own thing here?
tia
Kate
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
Quoted 7 lines · kate
so the drop-all would be..?
iptables -A INPUT -p TCP -i eth0 -s 0/0 -j DROP
or did I just invent my own thing here?
tia
Kate
well--the standard way would be to set the policy of the built-in chain to DROP; i.e.,
iptables -P INPUT DROP
the same can be achieved by making the last rule in the chain a drop rule, like
iptables -A INPUT -j DROP
but that gets messy if you want to append rules "on the fly" so the policy method is preferred.
-j
Signature · 1 line
Jason Opperisano <[email protected]>
Quoted 20 lines · --- Jason Opperisano
Quoted 7 lines · kate
so the drop-all would be..?
iptables -A INPUT -p TCP -i eth0 -s 0/0 -j DROP
or did I just invent my own thing here?
tia
Katewell--the standard way would be to set the policy of the built-in chain
to DROP; i.e.,iptables -P INPUT DROP
the same can be achieved by making the last rule in the chain a drop
rule, like
Quoted 5 lines
iptables -A INPUT -j DROP
but that gets messy if you want to append rules "on the fly" so the
policy method is preferred.
Last question-
I have this at the top of my script, We should be good to go with this right ?
#(1) Policies (default)
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
or do we need something below part 3
iptables -A INPUT -p TCP -i eth0 -s 123.45.1.1
--destination-port 21 -j okay # userA
iptables -A INPUT -p TCP -i eth0 -s 123.45.0.0/16
--destination-port 22 -j okay #users A - Z
like ?
iptables -A INPUT -j DROP
many thanks for all your help. At least the LAN works! Kate
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
Quoted 8 lines · kate
Last question-
I have this at the top of my script, We should be good to go with this right ?#(1) Policies (default)
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
yes--we're good to go...
Quoted 9 lines
or do we need something below part 3
iptables -A INPUT -p TCP -i eth0 -s 123.45.1.1
--destination-port 21 -j okay # userA
iptables -A INPUT -p TCP -i eth0 -s 123.45.0.0/16
--destination-port 22 -j okay #users A - Zlike ?
iptables -A INPUT -j DROP
this would be redundant with "-P INPUT DROP" although it's worth noting that this last rule would catch all the traffic, and the INPUT policy counters would forever remain at zero.
i personally like to make my last rule some sort of logging rule--so in the event i'm blocking something i shouldn't--i have a record of what it looks like...i think my current iteration of the "log everything that's about to be dropped by the chain policy" rule looks something like:
iptables -A INPUT -m limit --limit 1/sec --limit-burst 3 \
-j LOG --log-level 4 --log-prefix "FW DROP INPUT: "
-j
Signature · 1 line
Jason Opperisano <[email protected]>