Skip to contentSkip to conversation

How to ACCEPT or DENY or DROP and also LOG in the same rule ?

DISCUSSION Orca J. 5 participants 7 messages Jul 4, 2002

lore
Share & tools
lore

Orca J.

author
#0 lore raw

Hi
I want to both DENY and LOG in the same rule ? or ACCEPT and LOG , or DENY
and LOG
Thanks

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx

#1 lore raw

I don't beleive you can.

Just do a rule pair:

<somerule to match> -j LOG
<somerule to match> -j ACCEPT

I think that, since LOG doesn't cause the packet to leave the table (ACCEPT and DROP do), it will continue traversal of the table until a match/target that does cause it to leave the table is found. So the matching DROP or ACCEPT rule will then dispose the packet as you wish after it was logged.

Cheers,
Michael

Quoted 11 lines · Orca J.

Hi
I want to both DENY and LOG in the same rule ? or ACCEPT and LOG , or
DENY and LOG
Thanks

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx

#2 lore raw
In reply to Orca J.
Quoted 3 lines · Orca J.

Hi
I want to both DENY and LOG in the same rule ? or ACCEPT and LOG , or
DENY and LOG

You can't put them both in the same rule, butyou can create a user-defined chain and jump to that:

iptables -N LOGDROP
iptables -A LOGDROP -j LOG --log-options........
iptables -A LOGDROP -j DROP

Then use that single target in your rules:

iptables -A INPUT -i eth0 -j LOGDROP

Antony/.

#3 lore raw

Hello,

Actually you can:
Rule #1 is to log
Rule #2 is to deny

Works In any chain.

Ed

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Antony Stone
Sent: Thursday, July 04, 2002 3:51 AM
To: [email protected]
Subject: Re: How to ACCEPT or DENY or DROP and also LOG in the same rule ?

Quoted 2 lines · Orca J.

Hi
I want to both DENY and LOG in the same rule ? or ACCEPT and LOG ,

or

Quoted 1 line

DENY and LOG

You can't put them both in the same rule, butyou can create a user-defined
chain and jump to that:

iptables -N LOGDROP
iptables -A LOGDROP -j LOG --log-options........
iptables -A LOGDROP -j DROP

Then use that single target in your rules:

iptables -A INPUT -i eth0 -j LOGDROP

Antony/.

#4 lore raw
Quoted 5 lines · Ed Street

Hello,

Actually you can:
Rule #1 is to log
Rule #2 is to deny

The original question was: I want to both DENY and LOG *in the same rule*.

Other posters suggested doing it in two rules, but this can make the rulesets unnecessarily long and tedious; it's far easier to read if you create your own chain to do the two operations and then call it from a single rule when you want to both LOG and DROP.

Antony.

Quoted 31 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Antony Stone
Sent: Thursday, July 04, 2002 3:51 AM
To: [email protected]
Subject: Re: How to ACCEPT or DENY or DROP and also LOG in the same rule ?

Quoted 2 lines · Orca J.

Hi
I want to both DENY and LOG in the same rule ? or ACCEPT and LOG ,

or

Quoted 1 line

DENY and LOG

You can't put them both in the same rule, butyou can create a user-defined
chain and jump to that:

iptables -N LOGDROP
iptables -A LOGDROP -j LOG --log-options........
iptables -A LOGDROP -j DROP

Then use that single target in your rules:

iptables -A INPUT -i eth0 -j LOGDROP

Antony/.

#5 lore raw

Hello,

Ok fine. 1 line

Log_drop function, parameters, goes, here

The log_drop function would do the
Iptables foo log
Iptables foo drop

Ed

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Antony Stone
Sent: Thursday, July 04, 2002 11:01 AM
To: [email protected]
Subject: Re: How to ACCEPT or DENY or DROP and also LOG in the same rule ?

Quoted 5 lines · Ed Street

Hello,

Actually you can:
Rule #1 is to log
Rule #2 is to deny

The original question was: I want to both DENY and LOG *in the same rule*.

Other posters suggested doing it in two rules, but this can make the rulesets
unnecessarily long and tedious; it's far easier to read if you create your
own chain to do the two operations and then call it from a single rule when
you want to both LOG and DROP.

Antony.

Quoted 6 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Antony Stone
Sent: Thursday, July 04, 2002 3:51 AM
To: [email protected]
Subject: Re: How to ACCEPT or DENY or DROP and also LOG in the same

rule

Quoted 25 lines

?

Quoted 2 lines · Orca J.

Hi
I want to both DENY and LOG in the same rule ? or ACCEPT and LOG ,

or

Quoted 1 line

DENY and LOG

You can't put them both in the same rule, butyou can create a user-defined
chain and jump to that:

iptables -N LOGDROP
iptables -A LOGDROP -j LOG --log-options........
iptables -A LOGDROP -j DROP

Then use that single target in your rules:

iptables -A INPUT -i eth0 -j LOGDROP

Antony/.

#6 lore raw
In reply to Antony Stone

Short answer: you cant. ipchains '-l' options doesnt exists in iptables

Workaround: if you really need this to be done in one rule, you can
create a chain with those two commands and them use it.

iptables -N log_drop
iptables -A log_drop -j LOG --log-prefix "blabla: " ..... iptables -A log_drop -j DROP

then, in your other chains, when you need something to be dropped and
logged, you can do:

iptables -A INPUT -s something -d someaddress -j log_drop

This meets your 'requirements', as you're logging and dropping in the
SAME rule and you wont have unnecessary rules, as the 'log and drop' will be created just once.

Of course, '-j log_drop' can be used all the times you need it .....

This should do the trick ..... in fact, you'll HAVE to do something like
this, as ipchains '-l' really doesnt exists here.

I think you should think how good this can be. For example. I have a
script firewall based on iptables and I have lots of 'log drop' rules. Which one of them has a special log-prefix setting. I use each one of them in different situations, so my log shows exactly the dropped packet and WHERE it was dropped ( log-preffix ). I can easily know if a packet was dropped on the forward rule, input rule ......

Sincerily,
Leonardo Rodrigues

----- Original Message -----
From: "Antony Stone" <[email protected]>
To: <[email protected]>
Sent: Thursday, July 04, 2002 12:00 PM
Subject: Re: How to ACCEPT or DENY or DROP and also LOG in the same rule ?

Quoted 9 lines · Ed Street
Quoted 6 lines

Hello,

Actually you can:
Rule #1 is to log
Rule #2 is to deny

The original question was: I want to both DENY and LOG *in the same rule*.