All of lore.kernel.org
 help / color / mirror / Atom feed
* Is this possible?
@ 2004-04-22 11:30 Fisher Alex
  2004-04-22 11:45 ` Kiran Kumar
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Fisher Alex @ 2004-04-22 11:30 UTC (permalink / raw)
  To: netfilter

Hi.

I'll do my best to explain what I'm trying to acheive with a linux box 
and 3 NICS.

I have two sets of systems.  Each system has about 30 IP addresses 
spread across various bits of hardware.  The two systems are identical 
(ie have the same 30 IP addresses).  The addresses are all part of the 
class C subnet 192.168.0.*

The IP addresses for each system are now set in stone and can't be 
changed.  Furthermore, similar addresses are already in use on our network.

I've been given a set of IP addresses I CAN use (172.26.158.*)

A diagram might help here ...

   -----------        -----------------
   - System1 ---------|eth1            |
   -----------        |                |
                      |  Linux Router  |
                      |            eth0|------------Rest of the network
                      |                |
   -----------        |                |
   - System2 ---------|eth2            |
   -----------        ------------------

I also have an address I can use for eth0 which will make the router 
visible from machines on the rest of the network.  This can be set as 
the default gateway for connections to the 172.26.158.* subnet.

I would like PCs on the normal network to be able to connect with either 
system by addressing them with addresses off the 172.26.158 subnet. 
I'll assign 30 of these IPs to each system.

For example. 172.26.158.10 might be mapped onto 192.168.0.2 on eth1
whilst  172.26.158.50 might be mapped onto 192.168.0.2 on eth2

Is this at all possible?  I assume I'll need to use at least DNAT but 
also apply some other trickery to route to the correct interface.  As a 
newbie to IPTables, I'm not sure how I might even begin to set up rules 
for this.

Hopefully this is the sort of thing people want to do all the time and 
it will be easy :)

Any help would be very much appreciated.

Thanks,

Al




This email and any attachments are confidential to the intended recipient
and may also be privileged. If you are not the intended recipient please
delete it from your system and notify Thales Underwater Systems on +44 1963
370 551. You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.


^ permalink raw reply	[flat|nested] 21+ messages in thread
[parent not found: <65aa6af90505021204715af788@mail.gmail.com>]
* Is this possible?
@ 2005-02-11 16:06 Michael Thompson
  2005-02-13 12:18 ` Jose Maria Lopez Hernandez
  2005-02-14 16:54 ` Andrew Schulman
  0 siblings, 2 replies; 21+ messages in thread
From: Michael Thompson @ 2005-02-11 16:06 UTC (permalink / raw)
  To: netfilter

I have a issue where I cannot connect to my server because the firewall 
only allows ports 80 and 443 out.

I previously ran SSH on port 443 to overcome this, but I have had to 
implement a HTTPS solution for users who wanted secure access, so that 
is now gone.

This system has DNS records for ssh.server.co.uk and www.server.co.uk, 
so can I use IPTables or similar to recognise if it is being connected 
to via ssh.server.co.uk on port 443 and forward the traffic to port 22? 
If www.server.co.uk:443 is used apache gets the traffic? Or is this (As 
I suspect) Impossible?


^ permalink raw reply	[flat|nested] 21+ messages in thread
* Re: Is this possible?
@ 2004-04-27  9:57 T. Horsnell (tsh)
  0 siblings, 0 replies; 21+ messages in thread
From: T. Horsnell (tsh) @ 2004-04-27  9:57 UTC (permalink / raw)
  To: Alex.Fisher; +Cc: netfilter

>>>Hi.
>>>
>>>I'll do my best to explain what I'm trying to acheive with a linux box 
>>>and 3 NICS.
>>>
>>>I have two sets of systems.  Each system has about 30 IP addresses 
>>>spread across various bits of hardware.  The two systems are identical 
>>>(ie have the same 30 IP addresses).  The addresses are all part of the 
>>>class C subnet 192.168.0.*
>>>
>>>The IP addresses for each system are now set in stone and can't be 
>>>changed.  Furthermore, similar addresses are already in use on our
>network.
>>>
>>>I've been given a set of IP addresses I CAN use (172.26.158.*)
>>>
>>>A diagram might help here ...
>>>
>>>  -----------        -----------------
>>>  - System1 ---------|eth1            |
>>>  -----------        |                |
>>>                     |  Linux Router  |
>>>                     |            eth0|------------Rest of the network
>>>                     |                |
>>>  -----------        |                |
>>>  - System2 ---------|eth2            |
>>>  -----------        ------------------
>>>
>>>I also have an address I can use for eth0 which will make the router 
>>>visible from machines on the rest of the network.  This can be set as 
>>>the default gateway for connections to the 172.26.158.* subnet.
>>>
>>>I would like PCs on the normal network to be able to connect with either 
>>>system by addressing them with addresses off the 172.26.158 subnet. 
>>>I'll assign 30 of these IPs to each system.
>>>
>>>For example. 172.26.158.10 might be mapped onto 192.168.0.2 on eth1
>>>whilst  172.26.158.50 might be mapped onto 192.168.0.2 on eth2
>>>
>> 
>> 
>> I've always regarded netfilter as a symmetric thing, so is it possible to 
>> 
>> 1. apply a set of S/DNAT rules specifically to
>>    eth1 to map system1's 192 addresses to something else, 
>> 2. add a route to enable these new addresses to reach eth0
>> 3. add appropriate rules to the FORWARD chain for those NAT'd addresses
>>    if required
>> 4. add a suitable set of S/DNAT rules specifically for eth0
>>    to S/DNAT those new addresses to a unique subset of 172 addresses
>> 5. Do the same stuff for eth2 but 1. would not be necessary
>> 
>> 
>> Cheers,
>> Terry.
>
>Thanks for your help here.  Whilst it differs from what other people 
>have suggested, what you've said seems to make good sense.  Some 
>examples would really help me out.  For instance, is it just DNAT I'm 
>doing in 1 and 4 or do I also need to use SNAT?  I take it that 3. is 
>optional and only required if I require extra filtering/firewalling.
>
>How does this look?
>
>iptables -t nat -A PREROUTING -d 192.168.152.2 -o eth1 DNAT --to  193.168.152.2
>
>ip route add 193.168.152.0/24 dev eth1
>
>iptables -t nat -A PREROUTING -d 172.26.158.2 -o eth0 DNAT --to  193.168.152.2
>
>ip route add 192.168.152.0/24 dev eth2
>
>iptables -t nat -A PREROUTING -d 172.26.158.130 -o eth0 DNAT --to  192.168.152.2
>
>ip route add default dev eth0 via 192.168.152.1
>

Ah. I didnt read your first query carefully enough. Are you really
wanting to  map each 192 subnet into a unique bit of 172
address space so that you dont have to make any config changes
to machines in 172 in order for them to access 192-space? I dont know if
this is possible. It implies that eth0 would have to respond to the whole
bunch of 172 ip addresses which you had reserved for your 192 nets, and
would also have to know that those packets were not intended for *it*,
but had to be forwarded on somewhere else. How would this be achieved?
It sounds like some sort of NAT'ing bridge, which is beyond my experience.
Maybe static entries in eth0's arp tables...


What I was suggesting is something that would map one of your 192 subnets
into a different bit of 192 space (so that the two 192 nets were
distinguishable), but that machines in 172 would still reference the 192
machines by their 192 addresses (a different set in the case of eth2, say).
This would require config'ing a static route in every machine in 172
which wanted to talk to the 192 boxes. Before carrying on, is this acceptable?

Cheers,
Terry.



^ permalink raw reply	[flat|nested] 21+ messages in thread
* Re: Is this possible?
@ 2004-04-26 10:03 Fisher Alex
  0 siblings, 0 replies; 21+ messages in thread
From: Fisher Alex @ 2004-04-26 10:03 UTC (permalink / raw)
  To: T. Horsnell (tsh); +Cc: netfilter

T. Horsnell (tsh) wrote:
>>Hi.
>>
>>I'll do my best to explain what I'm trying to acheive with a linux box 
>>and 3 NICS.
>>
>>I have two sets of systems.  Each system has about 30 IP addresses 
>>spread across various bits of hardware.  The two systems are identical 
>>(ie have the same 30 IP addresses).  The addresses are all part of the 
>>class C subnet 192.168.0.*
>>
>>The IP addresses for each system are now set in stone and can't be 
>>changed.  Furthermore, similar addresses are already in use on our
network.
>>
>>I've been given a set of IP addresses I CAN use (172.26.158.*)
>>
>>A diagram might help here ...
>>
>>  -----------        -----------------
>>  - System1 ---------|eth1            |
>>  -----------        |                |
>>                     |  Linux Router  |
>>                     |            eth0|------------Rest of the network
>>                     |                |
>>  -----------        |                |
>>  - System2 ---------|eth2            |
>>  -----------        ------------------
>>
>>I also have an address I can use for eth0 which will make the router 
>>visible from machines on the rest of the network.  This can be set as 
>>the default gateway for connections to the 172.26.158.* subnet.
>>
>>I would like PCs on the normal network to be able to connect with either 
>>system by addressing them with addresses off the 172.26.158 subnet. 
>>I'll assign 30 of these IPs to each system.
>>
>>For example. 172.26.158.10 might be mapped onto 192.168.0.2 on eth1
>>whilst  172.26.158.50 might be mapped onto 192.168.0.2 on eth2
>>
> 
> 
> I've always regarded netfilter as a symmetric thing, so is it possible to 
> 
> 1. apply a set of S/DNAT rules specifically to
>    eth1 to map system1's 192 addresses to something else, 
> 2. add a route to enable these new addresses to reach eth0
> 3. add appropriate rules to the FORWARD chain for those NAT'd addresses
>    if required
> 4. add a suitable set of S/DNAT rules specifically for eth0
>    to S/DNAT those new addresses to a unique subset of 172 addresses
> 5. Do the same stuff for eth2 but 1. would not be necessary
> 
> 
> Cheers,
> Terry.

Thanks for your help here.  Whilst it differs from what other people 
have suggested, what you've said seems to make good sense.  Some 
examples would really help me out.  For instance, is it just DNAT I'm 
doing in 1 and 4 or do I also need to use SNAT?  I take it that 3. is 
optional and only required if I require extra filtering/firewalling.

How does this look?

iptables -t nat -A PREROUTING -d 192.168.152.2 -o eth1 DNAT --to 
193.168.152.2

ip route add 193.168.152.0/24 dev eth1

iptables -t nat -A PREROUTING -d 172.26.158.2 -o eth0 DNAT --to 
193.168.152.2

ip route add 192.168.152.0/24 dev eth2

iptables -t nat -A PREROUTING -d 172.26.158.130 -o eth0 DNAT --to 
192.168.152.2

ip route add default dev eth0 via 192.168.152.1

Thanks,
Alex
This email and any attachments are confidential to the intended recipient
and may also be privileged. If you are not the intended recipient please
delete it from your system and notify Thales Underwater Systems on +44 1963
370 551. You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.


^ permalink raw reply	[flat|nested] 21+ messages in thread
* Re: Is this possible?
@ 2004-04-22 13:08 Fisher Alex
  0 siblings, 0 replies; 21+ messages in thread
From: Fisher Alex @ 2004-04-22 13:08 UTC (permalink / raw)
  To: netfilter

Antony Stone wrote:
> On Thursday 22 April 2004 1:36 pm, Fisher Alex wrote:
> 
> 
>>>However, if someone is adamant that you need to set up network
>>
>>connectivity
>>
>>
>>>between machines with such an unfriendly combination of IP addresses, I
>>>suggest you simply set up multiple host-specific routes on the netflter
>>>machine, telling it where to find each different 192.168.0.* destination
>>>address, and don't have a standard 192.168.0.0/24 route on that system.
>>
>>Unfortunately, this is exactly what I can't do :(  This is because there
>>are two of each 192.168.0.* IP address.  The original destination IP
>>address has to taken into account when determining whether packets route
>>through eth1 or eth2.
> 
> 
> Have you considered using two netfilter boxes, one DNATting from 
> 172.26.158.1-30 to 192.168.0.1-30 (network A), and the other DNATting from

> 172.26.158.31-60 to 192.168.0.1-30 (network B)?
> 
> Regards,
> 
> Antony
> 

Its just crossing my mind now :)

I've got 'use netfilter MARK value as routing key' switched on in the 
kernel, so I think I'll give it a go before quitting and finding a 2nd box.

Al
This email and any attachments are confidential to the intended recipient
and may also be privileged. If you are not the intended recipient please
delete it from your system and notify Thales Underwater Systems on +44 1963
370 551. You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.


^ permalink raw reply	[flat|nested] 21+ messages in thread
* Re: Is this possible?
@ 2004-04-22 12:36 Fisher Alex
  2004-04-22 13:03 ` Antony Stone
  0 siblings, 1 reply; 21+ messages in thread
From: Fisher Alex @ 2004-04-22 12:36 UTC (permalink / raw)
  To: netfilter

> However, if someone is adamant that you need to set up network
connectivity 
> between machines with such an unfriendly combination of IP addresses, I 
> suggest you simply set up multiple host-specific routes on the netflter 
> machine, telling it where to find each different 192.168.0.* destination 
> address, and don't have a standard 192.168.0.0/24 route on that system.

Unfortunately, this is exactly what I can't do :(  This is because there 
are two of each 192.168.0.* IP address.  The original destination IP 
address has to taken into account when determining whether packets route 
through eth1 or eth2.

I like the idea of MARKing the packets before they are routed.  DNATing 
them and then routing based on how they were previously MARKed.  As I 
get more comfortable with this (assuming nobody claims I'm trying to do 
the impossible), I'll try and put together some rules I might use to 
accomplish this.

Al
This email and any attachments are confidential to the intended recipient
and may also be privileged. If you are not the intended recipient please
delete it from your system and notify Thales Underwater Systems on +44 1963
370 551. You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.


^ permalink raw reply	[flat|nested] 21+ messages in thread
* is this possible ?
@ 2004-04-10 20:27 Syed Faisal Gillani
  2004-04-10 20:54 ` Frederic de Villamil
  0 siblings, 1 reply; 21+ messages in thread
From: Syed Faisal Gillani @ 2004-04-10 20:27 UTC (permalink / raw)
  To: netfilter

is it possible in iptables to FW a port traffic (eg 80) to an internal =
ipaddress of a webserver ?

Syed Faisal Gillani
ClickOnline Networks
http://clickonlinenetworks.com

E-mail powered by ClickOnline Networks


^ permalink raw reply	[flat|nested] 21+ messages in thread
* is this possible ?
@ 2004-04-10 20:14 Admin
  0 siblings, 0 replies; 21+ messages in thread
From: Admin @ 2004-04-10 20:14 UTC (permalink / raw)
  To: netfilter

is it possible in iptables to FW a port traffic (eg 80) to an internal =
ipaddress of a webserver ?

Syed Faisal Gillani

ClickOnline Networks
http://clickonlinenetworks.com

E-mail powered by ClickOnline Networks


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2005-05-02 19:34 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-22 11:30 Is this possible? Fisher Alex
2004-04-22 11:45 ` Kiran Kumar
2004-04-22 12:12 ` Antony Stone
2004-04-22 12:24   ` David Cannings
2004-04-22 12:44     ` Antony Stone
2004-04-23  8:49 ` T. Horsnell (tsh)
     [not found] <65aa6af90505021204715af788@mail.gmail.com>
2005-05-02 19:17 ` Edmundo Carmona
2005-05-02 19:34   ` Guy
  -- strict thread matches above, loose matches on Subject: below --
2005-02-11 16:06 Michael Thompson
2005-02-13 12:18 ` Jose Maria Lopez Hernandez
2005-02-14 16:54 ` Andrew Schulman
2005-02-15  4:25   ` Alex Samad
2005-02-15  6:20     ` Michael Thompson
2004-04-27  9:57 T. Horsnell (tsh)
2004-04-26 10:03 Fisher Alex
2004-04-22 13:08 Fisher Alex
2004-04-22 12:36 Fisher Alex
2004-04-22 13:03 ` Antony Stone
2004-04-10 20:27 is this possible ? Syed Faisal Gillani
2004-04-10 20:54 ` Frederic de Villamil
2004-04-10 20:14 Admin

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.