1 |
Hi, |
2 |
|
3 |
|
4 |
you can define a rule like that: |
5 |
|
6 |
iptables -A FORWARD -s 192.168.235.43,192.168.235.46 -d |
7 |
10.0.0.1,192.168.0.1 -j ACCEPT |
8 |
|
9 |
it will create 4 rules. |
10 |
|
11 |
be sure to activate Networking support->Networking options->Network |
12 |
packet filtering framework->Core Netfilter Configuration->iprange |
13 |
address range match support |
14 |
|
15 |
Now you can do something like |
16 |
|
17 |
iptables -A FORWARD -m iprange --src-range '10.0.0.1-10.0.0.44' -j |
18 |
ACCEPT |
19 |
|
20 |
hope it helps |
21 |
|
22 |
-Stefan |
23 |
|
24 |
On Mon, Apr 05, 2010 at 07:32:17PM +0200, Jarry wrote: |
25 |
> Hi |
26 |
> |
27 |
> I'd like to ask if there is some way to include multiple discrete |
28 |
> hosts/IP's in --source and --destination options of iptables. |
29 |
> |
30 |
> I'm trying to write firewall rules for my server, but it has |
31 |
> 12 IP's from different segments (and maybe it gets a few more |
32 |
> later), and the script grows up as I have to write nearly |
33 |
> identical rules with difference only in -s/-d IP's. |
34 |
> |
35 |
> What I'm looking for is a way to define some variable at the |
36 |
> beginning of my script, like MY_IP="IP1 IP2 IP3 IP4..." and |
37 |
> later to use is in rules (iptables -A INPUT -s $MY_IP...). |
38 |
> But I do not know how to use it. As far as I understand it, |
39 |
> --source/--destination accepts only single IP's or continuous |
40 |
> IP-segments... |
41 |
> |
42 |
> Jarry |
43 |
> |
44 |
> -- |
45 |
> _______________________________________________________________ |
46 |
> This mailbox accepts e-mails only from selected mailing-lists! |
47 |
> Everything else is considered to be spam and therefore deleted. |
48 |
> |