All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joel Newkirk <netfilter@newkirk.us>
To: Steve M Bibayoff <smb23@csufresno.edu>, netfilter@lists.netfilter.org
Subject: Re: Using an device alias?
Date: Fri, 3 Jan 2003 22:33:47 -0500	[thread overview]
Message-ID: <200301032233.47877.netfilter@newkirk.us> (raw)
In-Reply-To: <b74ecb8788.b8788b74ec@cvip.net>

On Friday 03 January 2003 02:28 pm, Steve M Bibayoff wrote:
> Is it possible to use iptables with a device alias
> (ex.. eth0:1)? I tries to add a filter rule and got
> an error:
> % iptables -t filter -I INPUT -i eth0:1 -j ACCEPT
> Warning: wierd character in interface `eth0:1' (No
> aliases, :, ! or *).

Well, the warning says it pretty clearly, it seems.  However, I have an 
idea on this.  Actually three, presented in order from simplest to most 
complicated.

Solution #1:
Since this is the INPUT chain, then the local machine clearly is the 
destination.  (unless you are using the REDIRECT target in nat 
PREROUTING)  I suggest you try something like:

iptables -A INPUT -i eth0 -d a.b.c.d...
iptables -A INPUT -i eth0 -d e.f.g.h...

This should catch the two aliased IP's independantly.  

Now if this were FORWARD chain traffic, this test wouldn't work, since 
the destination IP can in principle be anything at all, but by 
definition will NOT be an IP of the local box.  Even if it originally 
WAS addressed to this box, to appear in FORWARD it would have to be 
DNATted, and would then have the new IP.

Solution #2:
If eth0 is local, then I presume you have two different subnets connected 
to it, and want it to respond to both.  If this is the case, then you 
could test for which subnet the source IP is in rather than which destip 
is used.  Testing the source ip range would work in both INPUT and 
FORWARD chains, for traffic coming in on that interface (or its alias), 
while the same approach for destip should work for FORWARD or OUTPUT 
traffic going back out that interface. (note that -o eth0 would NOT be a 
valid test in FORWARD or OUTPUT, however, so you'd only be able to test 
destination IP)  Something like:

iptables -A FORWARD -i eth0 -s 10.0.0.0/16...
iptables -A FORWARD -i eth0 -s 10.1.0.0/16...

Solution #3:
If however eth0 is a connection to the internet with multiple IP's, (or 
for some unfathomable reason you have two independant IP's on the same 
interface that are on the same subnet...) NEITHER of these approaches 
can work in FORWARD chain, but there's still a possibility, by catching 
them inbound in mangle PREROUTING and marking them based on destIP, 
which will still be the 'real' IPs prior to DNAT in nat PREROUTING 
(which is implicit in such packets being in the FORWARD chain) and then 
in FORWARD you can match marks and handle them separately based on that.

iptables -t mangle -A PREROUTING -i eth0 -d a.b.c.d -j MARK --set-mark 2
iptables -t mangle -A PREROUTING -i eth0 -d e.f.g.h -j MARK --set-mark 3
iptables -A FORWARD -m mark --mark 2...
iptables -A FORWARD -m mark --mark 3...

This presumes that you aren't using packet marking for anything else, 
like routing decisions or load balancing, but if you are then you can 
possibly dovetail the two uses. (or switch to marks for filtering, TOS 
for routing)  This has the advantage of being a valid test in any chain 
and table, once the mark is in place.

j



  reply	other threads:[~2003-01-04  3:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-03 19:28 Using an device alias? Steve M Bibayoff
2003-01-04  3:33 ` Joel Newkirk [this message]
     [not found]   ` <3E19CD4E.2050700@csufresno.edu>
     [not found]     ` <3E19DD6B.7070503@csufresno.edu>
2003-01-06 19:56       ` Steve
2003-01-06 21:41         ` Joel Newkirk
2003-01-06  5:30 ` Raymond Leach
2003-01-07 17:23 ` WA Support
  -- strict thread matches above, loose matches on Subject: below --
2003-01-03 19:07 Steve M Bibayoff

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=200301032233.47877.netfilter@newkirk.us \
    --to=netfilter@newkirk.us \
    --cc=netfilter@lists.netfilter.org \
    --cc=smb23@csufresno.edu \
    /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.