From: "Walter D. Wyndroski" <wdwrn@friendlycity.net>
To: lartc@vger.kernel.org
Subject: [LARTC] iptables question
Date: Thu, 23 Oct 2003 03:45:01 +0000 [thread overview]
Message-ID: <marc-lartc-106688197329796@msgid-missing> (raw)
[-- Attachment #1: Type: text/plain, Size: 3051 bytes --]
First off, I know this is the LARTC list, but I've been living on this list for over a year now. :) Now with that said, I'm probably going to get flamed for my question. :)
I've read that iptables is a first match wins system. My recent experience is showing that it is a last match wins. I understand that if a packet is matched in prerouting chain, it may be matched again in a subsequent chain unless the jump target was drop.
NOTE: I am not using iptables as a true firewall, much as most people on this list do not. I'm primarily using iptables to mark packets and drop them for securing my network and to deny all traffic to my router except for a few exclusive port.s
The following is an excerpt from my router script on how I'm handling certain traffic to my router and this works: (This example is a last match wins)
#Deny All Traffic to Interface except SSH and ICMP
$IPTABLES -A FORWARD -i eth+ -t mangle --dst 172.20.0.5 -p icmp -j ACCEPT #CMTS Link
$IPTABLES -A FORWARD -i eth+ -t mangle --dst 172.20.0.5 -p ! tcp -j DROP #CMTS Link
$IPTABLES -A FORWARD -i eth+ -t mangle --dst 172.20.0.5 -p tcp --dport ! 22 -j DROP #CMTS Link
##Allow SNMP Calls Via MRTG To This Interface Only
$IPTABLES -A FORWARD -i eth3 -t mangle --src 66.28.168.226 --dst 172.20.0.5 -p udp --dport 161 -j ACCEPT
$IPTABLES -A FORWARD -i eth3 -t mangle --src 66.28.168.226 --dst 172.20.0.5 -p udp --dport 162 -j ACCEPT
This is how I was doing it and it worked: (This example is a first match wins)
(note: I was routing the fwmark 1 to blackhole)
##Allow SNMP Calls Via MRTG To This Interface Only
$IPTABLES -A PREROUTING -i eth3 -t mangle --src 66.28.168.226 --dst 172.20.0.5 -p udp --dport 161 -j ACCEPT
$IPTABLES -A PREROUTING -i eth3 -t mangle --src 66.28.168.226 --dst 172.20.0.5 -p udp --dport 162 -j ACCEPT
#Deny All Traffic to Interface except SSH and ICMP
$IPTABLES -A PREROUTING -i eth+ -t mangle --dst 172.20.0.5 -p icmp -j ACCEPT #CMTS Link
$IPTABLES -A PREROUTING -i eth+ -t mangle --dst 172.20.0.5 -p ! tcp -j MARK --set-mark 1 #CMTS Link
$IPTABLES -A PREROUTING -i eth+ -t mangle --dst 172.20.0.5 -p tcp --dport ! 22 -j MARK --set-mark 1 #CMTS Link
I just need someone to tell me when is iptables using first match wins versus last match wins. I think I am missing something but I am not sure. I stay so busy with other tasks that I cannot devote the time that I need and would like to this. Anyway, many thanks in advance.
Walt Wyndroski
**********************************************************************************************
* This message has been scanned by CityNET's email scanner for viruses and dangerous content *
* and is believed to be clean. CityNET is proud to use MailScanner. For more information *
* concerning MailScanner, visit http://www.mailscanner.info *
**********************************************************************************************
[-- Attachment #2: Type: text/html, Size: 4506 bytes --]
next reply other threads:[~2003-10-23 3:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-23 3:45 Walter D. Wyndroski [this message]
2003-10-23 14:50 ` [LARTC] iptables question Walter D. Wyndroski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=marc-lartc-106688197329796@msgid-missing \
--to=wdwrn@friendlycity.net \
--cc=lartc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.