* Public IP to Private IP
@ 2014-01-27 19:22 Scott Mayo
2014-01-27 19:36 ` Robby Workman
` (5 more replies)
0 siblings, 6 replies; 16+ messages in thread
From: Scott Mayo @ 2014-01-27 19:22 UTC (permalink / raw)
To: netfilter
I am having some troubles getting my public IPs routed to my private IPs.
Here is an example.
Private IP of the main server with my IPTables: 192.168.0.1
Public IP of the main server: 1.1.1.1
I also have 1.1.1.2 and 1.1.1.3 as public IPs attached to the public nic.
Domain name example.org is pointed to 1.1.1.2
I am trying to get the following public IPs to Private IPs:
1.1.1.2 -> 192.168.0.2
1.1.1.3 -> 192.168.0.3
If I am outside my network and go to example.org, it seems to work fine.
If I am inside my network and go to 192.168.0.2 then it works fine.
If I go to example.org from inside my network then it goes back to
192.168.0.1 instead of 192.168.0.2
Maybe this does not have to do with IPTables even since it works with
an IP, but I thought I would ask here. I do not have an internal DNS
server.
Here are the rules that I have:
IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT
--to-destination 192.168.0.2
IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -j SNAT --to-destination 1.1.1.2
Any suggestions would be appreciated.
Thanks.
--
Scott Mayo
Mayo's Pioneer Seeds PH: 573-568-3235 CE: 573-614-2138
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Public IP to Private IP
2014-01-27 19:22 Public IP to Private IP Scott Mayo
@ 2014-01-27 19:36 ` Robby Workman
2014-01-27 20:08 ` Mike Wright
` (4 subsequent siblings)
5 siblings, 0 replies; 16+ messages in thread
From: Robby Workman @ 2014-01-27 19:36 UTC (permalink / raw)
To: Scott Mayo; +Cc: netfilter
On Mon, 27 Jan 2014 13:22:17 -0600
Scott Mayo <scotgmayo@gmail.com> wrote:
> I am having some troubles getting my public IPs routed to my private
> IPs.
>
> Here is an example.
> Private IP of the main server with my IPTables: 192.168.0.1
> Public IP of the main server: 1.1.1.1
> I also have 1.1.1.2 and 1.1.1.3 as public IPs attached to the public
> nic. Domain name example.org is pointed to 1.1.1.2
>
> I am trying to get the following public IPs to Private IPs:
> 1.1.1.2 -> 192.168.0.2
> 1.1.1.3 -> 192.168.0.3
>
> If I am outside my network and go to example.org, it seems to work
> fine. If I am inside my network and go to 192.168.0.2 then it works
> fine. If I go to example.org from inside my network then it goes back
> to 192.168.0.1 instead of 192.168.0.2
>
> Maybe this does not have to do with IPTables even since it works with
> an IP, but I thought I would ask here. I do not have an internal DNS
> server.
>
> Here are the rules that I have:
>
> IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT
> --to-destination 192.168.0.2
> IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -j SNAT
> --to-destination 1.1.1.2
>
> Any suggestions would be appreciated.
The best solution (IMHO) is to handle it internally with DNS, i.e.
have the names you expect to see on those public ip addresses resolve
to the internal addresses from inside the local network.
-RW
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Public IP to Private IP
2014-01-27 19:22 Public IP to Private IP Scott Mayo
2014-01-27 19:36 ` Robby Workman
@ 2014-01-27 20:08 ` Mike Wright
2014-01-27 20:46 ` Bob Reiber
` (3 subsequent siblings)
5 siblings, 0 replies; 16+ messages in thread
From: Mike Wright @ 2014-01-27 20:08 UTC (permalink / raw)
To: netfilter list
01/27/2014 11:22 AM, Scott Mayo wrote:
> I am having some troubles getting my public IPs routed to my private IPs.
>
> Here is an example.
> Private IP of the main server with my IPTables: 192.168.0.1
> Public IP of the main server: 1.1.1.1
> I also have 1.1.1.2 and 1.1.1.3 as public IPs attached to the public nic.
> Domain name example.org is pointed to 1.1.1.2
>
> I am trying to get the following public IPs to Private IPs:
> 1.1.1.2 -> 192.168.0.2
> 1.1.1.3 -> 192.168.0.3
>
> If I am outside my network and go to example.org, it seems to work fine.
> If I am inside my network and go to 192.168.0.2 then it works fine.
> If I go to example.org from inside my network then it goes back to
> 192.168.0.1 instead of 192.168.0.2
>
> Maybe this does not have to do with IPTables even since it works with
> an IP, but I thought I would ask here. I do not have an internal DNS
> server.
>
> Here are the rules that I have:
>
> IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT
> --to-destination 192.168.0.2
> IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -j SNAT --to-destination 1.1.1.2
>
Since you're not running internal DNS try this:
/etc/hosts
order hosts,bind
192.168.0.2 example.org
^ permalink raw reply [flat|nested] 16+ messages in thread
* RE: Public IP to Private IP
2014-01-27 19:22 Public IP to Private IP Scott Mayo
2014-01-27 19:36 ` Robby Workman
2014-01-27 20:08 ` Mike Wright
@ 2014-01-27 20:46 ` Bob Reiber
2014-01-27 20:48 ` Ray Soucy
` (2 subsequent siblings)
5 siblings, 0 replies; 16+ messages in thread
From: Bob Reiber @ 2014-01-27 20:46 UTC (permalink / raw)
To: Scott Mayo, netfilter@vger.kernel.org
My guess is that example.org resolves to your public ip address. Add example.org to your hosts file. This will resolve example.org to the local ip address when you are inside the firewall.
Bob Reiber
BK Sales and Service
Tel: (650) 376-1122
-----Original Message-----
From: netfilter-owner@vger.kernel.org [mailto:netfilter-owner@vger.kernel.org] On Behalf Of Scott Mayo
Sent: Monday, January 27, 2014 11:22 AM
To: netfilter@vger.kernel.org
Subject: Public IP to Private IP
I am having some troubles getting my public IPs routed to my private IPs.
Here is an example.
Private IP of the main server with my IPTables: 192.168.0.1 Public IP of the main server: 1.1.1.1 I also have 1.1.1.2 and 1.1.1.3 as public IPs attached to the public nic.
Domain name example.org is pointed to 1.1.1.2
I am trying to get the following public IPs to Private IPs:
1.1.1.2 -> 192.168.0.2
1.1.1.3 -> 192.168.0.3
If I am outside my network and go to example.org, it seems to work fine.
If I am inside my network and go to 192.168.0.2 then it works fine.
If I go to example.org from inside my network then it goes back to
192.168.0.1 instead of 192.168.0.2
Maybe this does not have to do with IPTables even since it works with an IP, but I thought I would ask here. I do not have an internal DNS server.
Here are the rules that I have:
IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT --to-destination 192.168.0.2 IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -j SNAT --to-destination 1.1.1.2
Any suggestions would be appreciated.
Thanks.
--
Scott Mayo
Mayo's Pioneer Seeds PH: 573-568-3235 CE: 573-614-2138
--
To unsubscribe from this list: send the line "unsubscribe netfilter" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Public IP to Private IP
2014-01-27 19:22 Public IP to Private IP Scott Mayo
` (2 preceding siblings ...)
2014-01-27 20:46 ` Bob Reiber
@ 2014-01-27 20:48 ` Ray Soucy
2014-01-27 21:01 ` Scott Mayo
2014-01-28 7:32 ` Rob Sterenborg (lists)
2014-02-24 18:22 ` Scott Mayo
5 siblings, 1 reply; 16+ messages in thread
From: Ray Soucy @ 2014-01-27 20:48 UTC (permalink / raw)
To: Scott Mayo; +Cc: netfilter list
The term you're looking for is "NAT reflection" or "hairpin NAT".
If you're not running split DNS, then trying to reach a system via its
"outside" IP from an internal system will present a problem because
the source IP of the request is seen as on-link by the server, so the
server responds directly from an unexpected source IP and the
requesting host drops the request.
You can get around this issue by NATing the return traffic when its to
and from the internal network.
Assuming that your inside interface is eth1, and your inside IP
network is 192.168.0.0/23:
iptables -A POSTROUTING -s 192.168.0.0/23 -d 192.168.0.0/23 -o eth1 -j
MASQUERADE
Split DNS, however, is a better approach, if you can do it (using
views in BIND).
On Mon, Jan 27, 2014 at 2:22 PM, Scott Mayo <scotgmayo@gmail.com> wrote:
> I am having some troubles getting my public IPs routed to my private IPs.
>
> Here is an example.
> Private IP of the main server with my IPTables: 192.168.0.1
> Public IP of the main server: 1.1.1.1
> I also have 1.1.1.2 and 1.1.1.3 as public IPs attached to the public nic.
> Domain name example.org is pointed to 1.1.1.2
>
> I am trying to get the following public IPs to Private IPs:
> 1.1.1.2 -> 192.168.0.2
> 1.1.1.3 -> 192.168.0.3
>
> If I am outside my network and go to example.org, it seems to work fine.
> If I am inside my network and go to 192.168.0.2 then it works fine.
> If I go to example.org from inside my network then it goes back to
> 192.168.0.1 instead of 192.168.0.2
>
> Maybe this does not have to do with IPTables even since it works with
> an IP, but I thought I would ask here. I do not have an internal DNS
> server.
>
> Here are the rules that I have:
>
> IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT
> --to-destination 192.168.0.2
> IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -j SNAT --to-destination 1.1.1.2
>
> Any suggestions would be appreciated.
> Thanks.
>
> --
> Scott Mayo
> Mayo's Pioneer Seeds PH: 573-568-3235 CE: 573-614-2138
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Ray Patrick Soucy
Network Engineer
University of Maine System
T: 207-561-3526
F: 207-561-3531
MaineREN, Maine's Research and Education Network
www.maineren.net
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Public IP to Private IP
2014-01-27 20:48 ` Ray Soucy
@ 2014-01-27 21:01 ` Scott Mayo
2014-01-27 21:30 ` Ray Soucy
2014-02-02 15:45 ` Pascal Hambourg
0 siblings, 2 replies; 16+ messages in thread
From: Scott Mayo @ 2014-01-27 21:01 UTC (permalink / raw)
To: Ray Soucy; +Cc: netfilter list
On Mon, Jan 27, 2014 at 2:48 PM, Ray Soucy <rps@maine.edu> wrote:
> The term you're looking for is "NAT reflection" or "hairpin NAT".
>
> If you're not running split DNS, then trying to reach a system via its
> "outside" IP from an internal system will present a problem because
> the source IP of the request is seen as on-link by the server, so the
> server responds directly from an unexpected source IP and the
> requesting host drops the request.
>
> You can get around this issue by NATing the return traffic when its to
> and from the internal network.
>
> Assuming that your inside interface is eth1, and your inside IP
> network is 192.168.0.0/23:
>
> iptables -A POSTROUTING -s 192.168.0.0/23 -d 192.168.0.0/23 -o eth1 -j
> MASQUERADE
>
That did not seem to work either. Getting the same results. Thanks.
> Split DNS, however, is a better approach, if you can do it (using
> views in BIND).
Yes, if I can get time to setup a Bind server. I just need some more time.
--
Scott Mayo
Mayo's Pioneer Seeds PH: 573-568-3235 CE: 573-614-2138
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Public IP to Private IP
2014-01-27 21:01 ` Scott Mayo
@ 2014-01-27 21:30 ` Ray Soucy
2014-02-02 15:45 ` Pascal Hambourg
1 sibling, 0 replies; 16+ messages in thread
From: Ray Soucy @ 2014-01-27 21:30 UTC (permalink / raw)
To: Scott Mayo; +Cc: netfilter list
That seems very strange,
Is the server hosted on the same system as the NAT box?
Did you flush the conntrack table or wait for timeouts after making the change?
On Mon, Jan 27, 2014 at 4:01 PM, Scott Mayo <scotgmayo@gmail.com> wrote:
> On Mon, Jan 27, 2014 at 2:48 PM, Ray Soucy <rps@maine.edu> wrote:
>> The term you're looking for is "NAT reflection" or "hairpin NAT".
>>
>> If you're not running split DNS, then trying to reach a system via its
>> "outside" IP from an internal system will present a problem because
>> the source IP of the request is seen as on-link by the server, so the
>> server responds directly from an unexpected source IP and the
>> requesting host drops the request.
>>
>> You can get around this issue by NATing the return traffic when its to
>> and from the internal network.
>>
>> Assuming that your inside interface is eth1, and your inside IP
>> network is 192.168.0.0/23:
>>
>> iptables -A POSTROUTING -s 192.168.0.0/23 -d 192.168.0.0/23 -o eth1 -j
>> MASQUERADE
>>
>
> That did not seem to work either. Getting the same results. Thanks.
>
>
>> Split DNS, however, is a better approach, if you can do it (using
>> views in BIND).
>
>
> Yes, if I can get time to setup a Bind server. I just need some more time.
>
> --
> Scott Mayo
> Mayo's Pioneer Seeds PH: 573-568-3235 CE: 573-614-2138
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Ray Patrick Soucy
Network Engineer
University of Maine System
T: 207-561-3526
F: 207-561-3531
MaineREN, Maine's Research and Education Network
www.maineren.net
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Public IP to Private IP
2014-01-27 19:22 Public IP to Private IP Scott Mayo
` (3 preceding siblings ...)
2014-01-27 20:48 ` Ray Soucy
@ 2014-01-28 7:32 ` Rob Sterenborg (lists)
2014-02-24 18:22 ` Scott Mayo
5 siblings, 0 replies; 16+ messages in thread
From: Rob Sterenborg (lists) @ 2014-01-28 7:32 UTC (permalink / raw)
To: Scott Mayo, netfilter
On 01/27/2014 08:22 PM, Scott Mayo wrote:
> I am having some troubles getting my public IPs routed to my private IPs.
>
> Here is an example.
> Private IP of the main server with my IPTables: 192.168.0.1
> Public IP of the main server: 1.1.1.1
> I also have 1.1.1.2 and 1.1.1.3 as public IPs attached to the public nic.
> Domain name example.org is pointed to 1.1.1.2
>
> I am trying to get the following public IPs to Private IPs:
> 1.1.1.2 -> 192.168.0.2
> 1.1.1.3 -> 192.168.0.3
>
> If I am outside my network and go to example.org, it seems to work fine.
> If I am inside my network and go to 192.168.0.2 then it works fine.
> If I go to example.org from inside my network then it goes back to
> 192.168.0.1 instead of 192.168.0.2
>
> Maybe this does not have to do with IPTables even since it works with
> an IP, but I thought I would ask here. I do not have an internal DNS
> server.
>
> Here are the rules that I have:
>
> IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT
> --to-destination 192.168.0.2
> IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -j SNAT --to-destination 1.1.1.2
>
> Any suggestions would be appreciated.
> Thanks.
As already explained, NAT-ing packets from your LAN back into your LAN
via the public IP (and receiving the answer packets) is a pain.
If you don't have split-DNS and don't want to install DNS, you might
want to look into a reverse proxy (I have good experiences with Nginx).
--
Rob
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Public IP to Private IP
2014-01-27 21:01 ` Scott Mayo
2014-01-27 21:30 ` Ray Soucy
@ 2014-02-02 15:45 ` Pascal Hambourg
2014-02-02 16:09 ` Mauricio Tavares
1 sibling, 1 reply; 16+ messages in thread
From: Pascal Hambourg @ 2014-02-02 15:45 UTC (permalink / raw)
To: Scott Mayo; +Cc: Ray Soucy, netfilter list
Hello,
Scott Mayo a écrit :
> On Mon, Jan 27, 2014 at 2:48 PM, Ray Soucy <rps@maine.edu> wrote:
>> The term you're looking for is "NAT reflection" or "hairpin NAT".
>>
>> If you're not running split DNS, then trying to reach a system via its
>> "outside" IP from an internal system will present a problem because
>> the source IP of the request is seen as on-link by the server, so the
>> server responds directly from an unexpected source IP and the
>> requesting host drops the request.
>>
>> You can get around this issue by NATing the return traffic when its to
>> and from the internal network.
>>
>> Assuming that your inside interface is eth1, and your inside IP
>> network is 192.168.0.0/23:
>>
>> iptables -A POSTROUTING -s 192.168.0.0/23 -d 192.168.0.0/23 -o eth1 -j
>> MASQUERADE
Instead of masquerading I would suggest to 1:1 map the source addresses
to a different (unused) private subnet, so that the source address seen
by the final server can be mapped back to the real source address.
E.g. :
iptables -A POSTROUTING -s 192.168.0.0/23 -d 192.168.0.0/23 -o eth1 \
-j NETMAP --to 192.168.8.0/23
> That did not seem to work either. Getting the same results. Thanks.
Also make sure that "reflected" packets from eth1 to eth1 (replace with
the real internal interface name) in the FORWARD chain are ACCEPTed.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Public IP to Private IP
2014-02-02 15:45 ` Pascal Hambourg
@ 2014-02-02 16:09 ` Mauricio Tavares
2014-02-02 16:36 ` Pascal Hambourg
0 siblings, 1 reply; 16+ messages in thread
From: Mauricio Tavares @ 2014-02-02 16:09 UTC (permalink / raw)
To: netfilter list
On Sun, Feb 2, 2014 at 10:45 AM, Pascal Hambourg <pascal@plouf.fr.eu.org> wrote:
> Hello,
>
> Scott Mayo a écrit :
>> On Mon, Jan 27, 2014 at 2:48 PM, Ray Soucy <rps@maine.edu> wrote:
>>> The term you're looking for is "NAT reflection" or "hairpin NAT".
>>>
>>> If you're not running split DNS, then trying to reach a system via its
>>> "outside" IP from an internal system will present a problem because
>>> the source IP of the request is seen as on-link by the server, so the
>>> server responds directly from an unexpected source IP and the
>>> requesting host drops the request.
>>>
>>> You can get around this issue by NATing the return traffic when its to
>>> and from the internal network.
>>>
>>> Assuming that your inside interface is eth1, and your inside IP
>>> network is 192.168.0.0/23:
>>>
>>> iptables -A POSTROUTING -s 192.168.0.0/23 -d 192.168.0.0/23 -o eth1 -j
>>> MASQUERADE
>
> Instead of masquerading I would suggest to 1:1 map the source addresses
> to a different (unused) private subnet, so that the source address seen
> by the final server can be mapped back to the real source address.
>
> E.g. :
> iptables -A POSTROUTING -s 192.168.0.0/23 -d 192.168.0.0/23 -o eth1 \
> -j NETMAP --to 192.168.8.0/23
>
Assuming 0.1 is the gateway, how about adding to its firewall
rules something like
iptables -t nat -A POSTROUTING -d 192.168.0.2 -s 192.168.0.0/24 -j
SNAT --to-source 192.168.0.1
(Adjust as needed)
>> That did not seem to work either. Getting the same results. Thanks.
>
> Also make sure that "reflected" packets from eth1 to eth1 (replace with
> the real internal interface name) in the FORWARD chain are ACCEPTed.
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Public IP to Private IP
2014-02-02 16:09 ` Mauricio Tavares
@ 2014-02-02 16:36 ` Pascal Hambourg
0 siblings, 0 replies; 16+ messages in thread
From: Pascal Hambourg @ 2014-02-02 16:36 UTC (permalink / raw)
To: Mauricio Tavares; +Cc: netfilter list
Mauricio Tavares a écrit :
> On Sun, Feb 2, 2014 at 10:45 AM, Pascal Hambourg <pascal@plouf.fr.eu.org> wrote:
>>>>
>>>> Assuming that your inside interface is eth1, and your inside IP
>>>> network is 192.168.0.0/23:
>>>>
>>>> iptables -A POSTROUTING -s 192.168.0.0/23 -d 192.168.0.0/23 -o eth1 -j
>>>> MASQUERADE
>> Instead of masquerading I would suggest to 1:1 map the source addresses
>> to a different (unused) private subnet, so that the source address seen
>> by the final server can be mapped back to the real source address.
>>
>> E.g. :
>> iptables -A POSTROUTING -s 192.168.0.0/23 -d 192.168.0.0/23 -o eth1 \
>> -j NETMAP --to 192.168.8.0/23
>
> Assuming 0.1 is the gateway, how about adding to its firewall
> rules something like
>
> iptables -t nat -A POSTROUTING -d 192.168.0.2 -s 192.168.0.0/24 -j
> SNAT --to-source 192.168.0.1
The result (N:1 mapping) would be the same as the above MASQUERADE rule
and hide the real source address from the final server.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Public IP to Private IP
2014-01-27 19:22 Public IP to Private IP Scott Mayo
` (4 preceding siblings ...)
2014-01-28 7:32 ` Rob Sterenborg (lists)
@ 2014-02-24 18:22 ` Scott Mayo
2014-02-24 19:13 ` Scott Mayo
5 siblings, 1 reply; 16+ messages in thread
From: Scott Mayo @ 2014-02-24 18:22 UTC (permalink / raw)
To: netfilter
On Mon, Jan 27, 2014 at 1:22 PM, Scott Mayo <scotgmayo@gmail.com> wrote:
> I am having some troubles getting my public IPs routed to my private IPs.
>
> Here is an example.
> Private IP of the main server with my IPTables: 192.168.0.1
> Public IP of the main server: 1.1.1.1
> I also have 1.1.1.2 and 1.1.1.3 as public IPs attached to the public nic.
> Domain name example.org is pointed to 1.1.1.2
>
> I am trying to get the following public IPs to Private IPs:
> 1.1.1.2 -> 192.168.0.2
> 1.1.1.3 -> 192.168.0.3
>
> If I am outside my network and go to example.org, it seems to work fine.
> If I am inside my network and go to 192.168.0.2 then it works fine.
> If I go to example.org from inside my network then it goes back to
> 192.168.0.1 instead of 192.168.0.2
>
> Maybe this does not have to do with IPTables even since it works with
> an IP, but I thought I would ask here. I do not have an internal DNS
> server.
>
> Here are the rules that I have:
>
> IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT
> --to-destination 192.168.0.2
> IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -j SNAT --to-destination 1.1.1.2
>
> Any suggestions would be appreciated.
> Thanks.
I ended up finishing my setup on my new filter server. I had not
messed with this problem and wanted to wait until I got it into place.
I am back to it now. I appreciate the suggestions so far. I am
getting ready to setup an internal DNS server, but until I do, I would
like to get the IPTABLES working.
Here are the IPTABLE rules that I have in place:
$IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT
--to-destination 192.168.0.2
$IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -s 192.168.0.0/16 -j
SNAT --to-source 1.1.1.2
$IPTABLES -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 1.1.1.1
Here is quick breakdown
ifcfg-eth0 = 1.1.1.1 #public IP of the main Squid/IPTABLES box
ifcfg-eth0:0 = 1.1.1.2 #Virtual IP which I want to forward on to the
other webserver box: example.org
example.org resolves to 1.1.1.2 fine
ifcfg-eth1 = 192.168.1.1 #private IP of the main Squid/IPTABLES box
192.168.1.2 #Is the private IP that I want forward on to the other
webserver box: example.org
My IPTABLES are on my Squid box. I have just played some more and
found that if I take the proxy settings out of my browser and type in
example.org in the URL, it works fine.
If I leave the proxy settings in and type in example.org then it comes
back to the main Squid box address of 192.168.1.1.
Any idea why that would matter? I do drop port 80 and port 3128 so
that the proxy cannot be gone around. For testing purposes though, I
took those two drops out and it is still doing it.
I'll get a copy of my IPTABLE rules and post also. Just thought I
would post this first and see if someone had an idea of what I might
be looking for.
--
Scott Mayo
Mayo's Pioneer Seeds
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Public IP to Private IP
2014-02-24 18:22 ` Scott Mayo
@ 2014-02-24 19:13 ` Scott Mayo
2014-02-24 21:56 ` Scott Mayo
0 siblings, 1 reply; 16+ messages in thread
From: Scott Mayo @ 2014-02-24 19:13 UTC (permalink / raw)
To: netfilter
On Mon, Feb 24, 2014 at 12:22 PM, Scott Mayo <scotgmayo@gmail.com> wrote:
> On Mon, Jan 27, 2014 at 1:22 PM, Scott Mayo <scotgmayo@gmail.com> wrote:
>> I am having some troubles getting my public IPs routed to my private IPs.
>>
>> Here is an example.
>> Private IP of the main server with my IPTables: 192.168.0.1
>> Public IP of the main server: 1.1.1.1
>> I also have 1.1.1.2 and 1.1.1.3 as public IPs attached to the public nic.
>> Domain name example.org is pointed to 1.1.1.2
>>
>> I am trying to get the following public IPs to Private IPs:
>> 1.1.1.2 -> 192.168.0.2
>> 1.1.1.3 -> 192.168.0.3
>>
>> If I am outside my network and go to example.org, it seems to work fine.
>> If I am inside my network and go to 192.168.0.2 then it works fine.
>> If I go to example.org from inside my network then it goes back to
>> 192.168.0.1 instead of 192.168.0.2
>>
>> Maybe this does not have to do with IPTables even since it works with
>> an IP, but I thought I would ask here. I do not have an internal DNS
>> server.
>>
>> Here are the rules that I have:
>>
>> IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT
>> --to-destination 192.168.0.2
>> IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -j SNAT --to-destination 1.1.1.2
>>
>> Any suggestions would be appreciated.
>> Thanks.
>
>
> I ended up finishing my setup on my new filter server. I had not
> messed with this problem and wanted to wait until I got it into place.
> I am back to it now. I appreciate the suggestions so far. I am
> getting ready to setup an internal DNS server, but until I do, I would
> like to get the IPTABLES working.
>
> Here are the IPTABLE rules that I have in place:
>
> $IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT
> --to-destination 192.168.0.2
> $IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -s 192.168.0.0/16 -j
> SNAT --to-source 1.1.1.2
> $IPTABLES -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 1.1.1.1
>
> Here is quick breakdown
> ifcfg-eth0 = 1.1.1.1 #public IP of the main Squid/IPTABLES box
> ifcfg-eth0:0 = 1.1.1.2 #Virtual IP which I want to forward on to the
> other webserver box: example.org
> example.org resolves to 1.1.1.2 fine
> ifcfg-eth1 = 192.168.1.1 #private IP of the main Squid/IPTABLES box
> 192.168.1.2 #Is the private IP that I want forward on to the other
> webserver box: example.org
>
> My IPTABLES are on my Squid box. I have just played some more and
> found that if I take the proxy settings out of my browser and type in
> example.org in the URL, it works fine.
>
> If I leave the proxy settings in and type in example.org then it comes
> back to the main Squid box address of 192.168.1.1.
>
> Any idea why that would matter? I do drop port 80 and port 3128 so
> that the proxy cannot be gone around. For testing purposes though, I
> took those two drops out and it is still doing it.
>
> I'll get a copy of my IPTABLE rules and post also. Just thought I
> would post this first and see if someone had an idea of what I might
> be looking for.
It just dawned on me that this may be pulling from the Squid cache so
I'll wait until after school and clear that. Maybe my IP rules are
correct now since it is working without going through the proxy.
Thanks.
--
Scott Mayo
Mayo's Pioneer Seeds
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Public IP to Private IP
2014-02-24 19:13 ` Scott Mayo
@ 2014-02-24 21:56 ` Scott Mayo
2014-02-25 18:06 ` Scott Mayo
0 siblings, 1 reply; 16+ messages in thread
From: Scott Mayo @ 2014-02-24 21:56 UTC (permalink / raw)
To: netfilter
On Mon, Feb 24, 2014 at 1:13 PM, Scott Mayo <scotgmayo@gmail.com> wrote:
> On Mon, Feb 24, 2014 at 12:22 PM, Scott Mayo <scotgmayo@gmail.com> wrote:
>> On Mon, Jan 27, 2014 at 1:22 PM, Scott Mayo <scotgmayo@gmail.com> wrote:
>>> I am having some troubles getting my public IPs routed to my private IPs.
>>>
>>> Here is an example.
>>> Private IP of the main server with my IPTables: 192.168.0.1
>>> Public IP of the main server: 1.1.1.1
>>> I also have 1.1.1.2 and 1.1.1.3 as public IPs attached to the public nic.
>>> Domain name example.org is pointed to 1.1.1.2
>>>
>>> I am trying to get the following public IPs to Private IPs:
>>> 1.1.1.2 -> 192.168.0.2
>>> 1.1.1.3 -> 192.168.0.3
>>>
>>> If I am outside my network and go to example.org, it seems to work fine.
>>> If I am inside my network and go to 192.168.0.2 then it works fine.
>>> If I go to example.org from inside my network then it goes back to
>>> 192.168.0.1 instead of 192.168.0.2
>>>
>>> Maybe this does not have to do with IPTables even since it works with
>>> an IP, but I thought I would ask here. I do not have an internal DNS
>>> server.
>>>
>>> Here are the rules that I have:
>>>
>>> IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT
>>> --to-destination 192.168.0.2
>>> IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -j SNAT --to-destination 1.1.1.2
>>>
>>> Any suggestions would be appreciated.
>>> Thanks.
>>
>>
>> I ended up finishing my setup on my new filter server. I had not
>> messed with this problem and wanted to wait until I got it into place.
>> I am back to it now. I appreciate the suggestions so far. I am
>> getting ready to setup an internal DNS server, but until I do, I would
>> like to get the IPTABLES working.
>>
>> Here are the IPTABLE rules that I have in place:
>>
>> $IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT
>> --to-destination 192.168.0.2
>> $IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -s 192.168.0.0/16 -j
>> SNAT --to-source 1.1.1.2
>> $IPTABLES -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 1.1.1.1
>>
>> Here is quick breakdown
>> ifcfg-eth0 = 1.1.1.1 #public IP of the main Squid/IPTABLES box
>> ifcfg-eth0:0 = 1.1.1.2 #Virtual IP which I want to forward on to the
>> other webserver box: example.org
>> example.org resolves to 1.1.1.2 fine
>> ifcfg-eth1 = 192.168.1.1 #private IP of the main Squid/IPTABLES box
>> 192.168.1.2 #Is the private IP that I want forward on to the other
>> webserver box: example.org
>>
>> My IPTABLES are on my Squid box. I have just played some more and
>> found that if I take the proxy settings out of my browser and type in
>> example.org in the URL, it works fine.
>>
>> If I leave the proxy settings in and type in example.org then it comes
>> back to the main Squid box address of 192.168.1.1.
>>
>> Any idea why that would matter? I do drop port 80 and port 3128 so
>> that the proxy cannot be gone around. For testing purposes though, I
>> took those two drops out and it is still doing it.
>>
>> I'll get a copy of my IPTABLE rules and post also. Just thought I
>> would post this first and see if someone had an idea of what I might
>> be looking for.
>
>
> It just dawned on me that this may be pulling from the Squid cache so
> I'll wait until after school and clear that. Maybe my IP rules are
> correct now since it is working without going through the proxy.
I just wiped my Squid cache and that was not it. I have even put in a
very, very simple set of rules that I will post below. example.org is
pointed to the 1.1.1.2 IP address.
If I go to example.org (private = 192.168.0.2/public = 1.1.1.2)
without the proxy settings in the browser to point to my Squid box
(192.168.0.1) then it resolves fine.
If I go to example.org with the proxy settings in my browser to point
to my Squid box then it takes me to the webserver on 192.168.0.1
(which is my squid box and has the IPTABLES on it).
I guess I am not understanding why it would make any difference if I
am directed through the proxy or not since everything goes through
this box one way or another. Here is the simple IPTABLES that I used
to test with.
Thanks for any info.
#!/bin/sh
EXT_IP="1.1.1.0/24"
EXT_IFACE="eth0"
EXT_BROADCAST="1.1.1.255"
INT_IP="192.168.0.1"
INT_IP_RANGE="192.168.0.0/16"
INT_IFACE="eth1"
LO_IFACE="lo"
LO_IP="127.0.0.1"
IPTABLES="/sbin/iptables"
/sbin/depmod -a
/sbin/modprobe ip_tables
/sbin/modprobe ip_conntrack
/sbin/modprobe iptable_filter
/sbin/modprobe iptable_mangle
/sbin/modprobe iptable_nat
/sbin/modprobe ipt_LOG
/sbin/modprobe ipt_limit
/sbin/modprobe ipt_state
#Non required modules
/sbin/modprobe ipt_owner
/sbin/modprobe ipt_REJECT
#/sbin/modprobe ipt_MASQUERADE
#/sbin/modprobe ip_conntrack_ftp
#/sbin/modprobe ip_conntrack_irc
#/sbin/modprobe ip_nat_ftp
#/sbin/modprobe ip_nat_irc
echo "1" > /proc/sys/net/ipv4/ip_forward
#Create default policies and FLUSH the chains
$IPTABLES -P INPUT ACCEPT
$IPTABLES -F INPUT
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -F OUTPUT
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -F FORWARD
$IPTABLES -F
$IPTABLES -t nat -F
$IPTABLES -t mangle -F
#Allow the local network
$IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT
--to-destination 192.168.0.2
$IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -s 192.168.0.0/16 -j
SNAT --to-source 1.1.1.2
$IPTABLES -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 1.1.1.1
--
Scott Mayo
Mayo's Pioneer Seeds
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Public IP to Private IP
2014-02-24 21:56 ` Scott Mayo
@ 2014-02-25 18:06 ` Scott Mayo
2014-02-25 18:12 ` Scott Mayo
0 siblings, 1 reply; 16+ messages in thread
From: Scott Mayo @ 2014-02-25 18:06 UTC (permalink / raw)
To: netfilter
On Mon, Feb 24, 2014 at 3:56 PM, Scott Mayo <scotgmayo@gmail.com> wrote:
> On Mon, Feb 24, 2014 at 1:13 PM, Scott Mayo <scotgmayo@gmail.com> wrote:
>> On Mon, Feb 24, 2014 at 12:22 PM, Scott Mayo <scotgmayo@gmail.com> wrote:
>>> On Mon, Jan 27, 2014 at 1:22 PM, Scott Mayo <scotgmayo@gmail.com> wrote:
>>>> I am having some troubles getting my public IPs routed to my private IPs.
>>>>
>>>> Here is an example.
>>>> Private IP of the main server with my IPTables: 192.168.0.1
>>>> Public IP of the main server: 1.1.1.1
>>>> I also have 1.1.1.2 and 1.1.1.3 as public IPs attached to the public nic.
>>>> Domain name example.org is pointed to 1.1.1.2
>>>>
>>>> I am trying to get the following public IPs to Private IPs:
>>>> 1.1.1.2 -> 192.168.0.2
>>>> 1.1.1.3 -> 192.168.0.3
>>>>
>>>> If I am outside my network and go to example.org, it seems to work fine.
>>>> If I am inside my network and go to 192.168.0.2 then it works fine.
>>>> If I go to example.org from inside my network then it goes back to
>>>> 192.168.0.1 instead of 192.168.0.2
>>>>
>>>> Maybe this does not have to do with IPTables even since it works with
>>>> an IP, but I thought I would ask here. I do not have an internal DNS
>>>> server.
>>>>
>>>> Here are the rules that I have:
>>>>
>>>> IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT
>>>> --to-destination 192.168.0.2
>>>> IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -j SNAT --to-destination 1.1.1.2
>>>>
>>>> Any suggestions would be appreciated.
>>>> Thanks.
>>>
>>>
>>> I ended up finishing my setup on my new filter server. I had not
>>> messed with this problem and wanted to wait until I got it into place.
>>> I am back to it now. I appreciate the suggestions so far. I am
>>> getting ready to setup an internal DNS server, but until I do, I would
>>> like to get the IPTABLES working.
>>>
>>> Here are the IPTABLE rules that I have in place:
>>>
>>> $IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT
>>> --to-destination 192.168.0.2
>>> $IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -s 192.168.0.0/16 -j
>>> SNAT --to-source 1.1.1.2
>>> $IPTABLES -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 1.1.1.1
>>>
>>> Here is quick breakdown
>>> ifcfg-eth0 = 1.1.1.1 #public IP of the main Squid/IPTABLES box
>>> ifcfg-eth0:0 = 1.1.1.2 #Virtual IP which I want to forward on to the
>>> other webserver box: example.org
>>> example.org resolves to 1.1.1.2 fine
>>> ifcfg-eth1 = 192.168.1.1 #private IP of the main Squid/IPTABLES box
>>> 192.168.1.2 #Is the private IP that I want forward on to the other
>>> webserver box: example.org
>>>
>>> My IPTABLES are on my Squid box. I have just played some more and
>>> found that if I take the proxy settings out of my browser and type in
>>> example.org in the URL, it works fine.
>>>
>>> If I leave the proxy settings in and type in example.org then it comes
>>> back to the main Squid box address of 192.168.1.1.
>>>
>>> Any idea why that would matter? I do drop port 80 and port 3128 so
>>> that the proxy cannot be gone around. For testing purposes though, I
>>> took those two drops out and it is still doing it.
>>>
>>> I'll get a copy of my IPTABLE rules and post also. Just thought I
>>> would post this first and see if someone had an idea of what I might
>>> be looking for.
>>
>>
>> It just dawned on me that this may be pulling from the Squid cache so
>> I'll wait until after school and clear that. Maybe my IP rules are
>> correct now since it is working without going through the proxy.
>
>
> I just wiped my Squid cache and that was not it. I have even put in a
> very, very simple set of rules that I will post below. example.org is
> pointed to the 1.1.1.2 IP address.
>
> If I go to example.org (private = 192.168.0.2/public = 1.1.1.2)
> without the proxy settings in the browser to point to my Squid box
> (192.168.0.1) then it resolves fine.
>
> If I go to example.org with the proxy settings in my browser to point
> to my Squid box then it takes me to the webserver on 192.168.0.1
> (which is my squid box and has the IPTABLES on it).
>
> I guess I am not understanding why it would make any difference if I
> am directed through the proxy or not since everything goes through
> this box one way or another. Here is the simple IPTABLES that I used
> to test with.
>
> Thanks for any info.
>
> #!/bin/sh
> EXT_IP="1.1.1.0/24"
> EXT_IFACE="eth0"
> EXT_BROADCAST="1.1.1.255"
>
> INT_IP="192.168.0.1"
> INT_IP_RANGE="192.168.0.0/16"
> INT_IFACE="eth1"
>
> LO_IFACE="lo"
> LO_IP="127.0.0.1"
>
> IPTABLES="/sbin/iptables"
>
> /sbin/depmod -a
>
> /sbin/modprobe ip_tables
> /sbin/modprobe ip_conntrack
> /sbin/modprobe iptable_filter
> /sbin/modprobe iptable_mangle
> /sbin/modprobe iptable_nat
> /sbin/modprobe ipt_LOG
> /sbin/modprobe ipt_limit
> /sbin/modprobe ipt_state
>
> #Non required modules
> /sbin/modprobe ipt_owner
> /sbin/modprobe ipt_REJECT
> #/sbin/modprobe ipt_MASQUERADE
> #/sbin/modprobe ip_conntrack_ftp
> #/sbin/modprobe ip_conntrack_irc
> #/sbin/modprobe ip_nat_ftp
> #/sbin/modprobe ip_nat_irc
>
> echo "1" > /proc/sys/net/ipv4/ip_forward
>
> #Create default policies and FLUSH the chains
> $IPTABLES -P INPUT ACCEPT
> $IPTABLES -F INPUT
> $IPTABLES -P OUTPUT ACCEPT
> $IPTABLES -F OUTPUT
> $IPTABLES -P FORWARD ACCEPT
> $IPTABLES -F FORWARD
>
> $IPTABLES -F
> $IPTABLES -t nat -F
> $IPTABLES -t mangle -F
>
> #Allow the local network
>
> $IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT
> --to-destination 192.168.0.2
> $IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -s 192.168.0.0/16 -j
> SNAT --to-source 1.1.1.2
> $IPTABLES -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 1.1.1.1
>
I am not sure if this thinking is correct or not, but here is what I
did. I got to looking at:
$IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -s 192.168.0.0/16 -j
SNAT --to-source 1.1.1.2
Since the browsers are pointed to the proxy at 192.168.0.1, I thought
that maybe once it comes from the squid box that maybe it is using the
public IP from eth0 instead of the private from eth1? I don't know
how all that works technically so I just removed the -s 192.168.0.0/16
in case it was trying to come from the public side which is
1.1.1.0/24.
As I said, not really sure if that is correct thinking or not, but now
it works fine.
--
Scott Mayo
Mayo's Pioneer Seeds
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Public IP to Private IP
2014-02-25 18:06 ` Scott Mayo
@ 2014-02-25 18:12 ` Scott Mayo
0 siblings, 0 replies; 16+ messages in thread
From: Scott Mayo @ 2014-02-25 18:12 UTC (permalink / raw)
To: netfilter
On Tue, Feb 25, 2014 at 12:06 PM, Scott Mayo <scotgmayo@gmail.com> wrote:
> On Mon, Feb 24, 2014 at 3:56 PM, Scott Mayo <scotgmayo@gmail.com> wrote:
>> On Mon, Feb 24, 2014 at 1:13 PM, Scott Mayo <scotgmayo@gmail.com> wrote:
>>> On Mon, Feb 24, 2014 at 12:22 PM, Scott Mayo <scotgmayo@gmail.com> wrote:
>>>> On Mon, Jan 27, 2014 at 1:22 PM, Scott Mayo <scotgmayo@gmail.com> wrote:
>>>>> I am having some troubles getting my public IPs routed to my private IPs.
>>>>>
>>>>> Here is an example.
>>>>> Private IP of the main server with my IPTables: 192.168.0.1
>>>>> Public IP of the main server: 1.1.1.1
>>>>> I also have 1.1.1.2 and 1.1.1.3 as public IPs attached to the public nic.
>>>>> Domain name example.org is pointed to 1.1.1.2
>>>>>
>>>>> I am trying to get the following public IPs to Private IPs:
>>>>> 1.1.1.2 -> 192.168.0.2
>>>>> 1.1.1.3 -> 192.168.0.3
>>>>>
>>>>> If I am outside my network and go to example.org, it seems to work fine.
>>>>> If I am inside my network and go to 192.168.0.2 then it works fine.
>>>>> If I go to example.org from inside my network then it goes back to
>>>>> 192.168.0.1 instead of 192.168.0.2
>>>>>
>>>>> Maybe this does not have to do with IPTables even since it works with
>>>>> an IP, but I thought I would ask here. I do not have an internal DNS
>>>>> server.
>>>>>
>>>>> Here are the rules that I have:
>>>>>
>>>>> IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT
>>>>> --to-destination 192.168.0.2
>>>>> IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -j SNAT --to-destination 1.1.1.2
>>>>>
>>>>> Any suggestions would be appreciated.
>>>>> Thanks.
>>>>
>>>>
>>>> I ended up finishing my setup on my new filter server. I had not
>>>> messed with this problem and wanted to wait until I got it into place.
>>>> I am back to it now. I appreciate the suggestions so far. I am
>>>> getting ready to setup an internal DNS server, but until I do, I would
>>>> like to get the IPTABLES working.
>>>>
>>>> Here are the IPTABLE rules that I have in place:
>>>>
>>>> $IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT
>>>> --to-destination 192.168.0.2
>>>> $IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -s 192.168.0.0/16 -j
>>>> SNAT --to-source 1.1.1.2
>>>> $IPTABLES -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 1.1.1.1
>>>>
>>>> Here is quick breakdown
>>>> ifcfg-eth0 = 1.1.1.1 #public IP of the main Squid/IPTABLES box
>>>> ifcfg-eth0:0 = 1.1.1.2 #Virtual IP which I want to forward on to the
>>>> other webserver box: example.org
>>>> example.org resolves to 1.1.1.2 fine
>>>> ifcfg-eth1 = 192.168.1.1 #private IP of the main Squid/IPTABLES box
>>>> 192.168.1.2 #Is the private IP that I want forward on to the other
>>>> webserver box: example.org
>>>>
>>>> My IPTABLES are on my Squid box. I have just played some more and
>>>> found that if I take the proxy settings out of my browser and type in
>>>> example.org in the URL, it works fine.
>>>>
>>>> If I leave the proxy settings in and type in example.org then it comes
>>>> back to the main Squid box address of 192.168.1.1.
>>>>
>>>> Any idea why that would matter? I do drop port 80 and port 3128 so
>>>> that the proxy cannot be gone around. For testing purposes though, I
>>>> took those two drops out and it is still doing it.
>>>>
>>>> I'll get a copy of my IPTABLE rules and post also. Just thought I
>>>> would post this first and see if someone had an idea of what I might
>>>> be looking for.
>>>
>>>
>>> It just dawned on me that this may be pulling from the Squid cache so
>>> I'll wait until after school and clear that. Maybe my IP rules are
>>> correct now since it is working without going through the proxy.
>>
>>
>> I just wiped my Squid cache and that was not it. I have even put in a
>> very, very simple set of rules that I will post below. example.org is
>> pointed to the 1.1.1.2 IP address.
>>
>> If I go to example.org (private = 192.168.0.2/public = 1.1.1.2)
>> without the proxy settings in the browser to point to my Squid box
>> (192.168.0.1) then it resolves fine.
>>
>> If I go to example.org with the proxy settings in my browser to point
>> to my Squid box then it takes me to the webserver on 192.168.0.1
>> (which is my squid box and has the IPTABLES on it).
>>
>> I guess I am not understanding why it would make any difference if I
>> am directed through the proxy or not since everything goes through
>> this box one way or another. Here is the simple IPTABLES that I used
>> to test with.
>>
>> Thanks for any info.
>>
>> #!/bin/sh
>> EXT_IP="1.1.1.0/24"
>> EXT_IFACE="eth0"
>> EXT_BROADCAST="1.1.1.255"
>>
>> INT_IP="192.168.0.1"
>> INT_IP_RANGE="192.168.0.0/16"
>> INT_IFACE="eth1"
>>
>> LO_IFACE="lo"
>> LO_IP="127.0.0.1"
>>
>> IPTABLES="/sbin/iptables"
>>
>> /sbin/depmod -a
>>
>> /sbin/modprobe ip_tables
>> /sbin/modprobe ip_conntrack
>> /sbin/modprobe iptable_filter
>> /sbin/modprobe iptable_mangle
>> /sbin/modprobe iptable_nat
>> /sbin/modprobe ipt_LOG
>> /sbin/modprobe ipt_limit
>> /sbin/modprobe ipt_state
>>
>> #Non required modules
>> /sbin/modprobe ipt_owner
>> /sbin/modprobe ipt_REJECT
>> #/sbin/modprobe ipt_MASQUERADE
>> #/sbin/modprobe ip_conntrack_ftp
>> #/sbin/modprobe ip_conntrack_irc
>> #/sbin/modprobe ip_nat_ftp
>> #/sbin/modprobe ip_nat_irc
>>
>> echo "1" > /proc/sys/net/ipv4/ip_forward
>>
>> #Create default policies and FLUSH the chains
>> $IPTABLES -P INPUT ACCEPT
>> $IPTABLES -F INPUT
>> $IPTABLES -P OUTPUT ACCEPT
>> $IPTABLES -F OUTPUT
>> $IPTABLES -P FORWARD ACCEPT
>> $IPTABLES -F FORWARD
>>
>> $IPTABLES -F
>> $IPTABLES -t nat -F
>> $IPTABLES -t mangle -F
>>
>> #Allow the local network
>>
>> $IPTABLES -t nat -A PREROUTING -d 1.1.1.2 -p tcp -j DNAT
>> --to-destination 192.168.0.2
>> $IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -s 192.168.0.0/16 -j
>> SNAT --to-source 1.1.1.2
>> $IPTABLES -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 1.1.1.1
>>
>
> I am not sure if this thinking is correct or not, but here is what I
> did. I got to looking at:
> $IPTABLES -t nat -A POSTROUTING -d 192.168.0.2 -s 192.168.0.0/16 -j
> SNAT --to-source 1.1.1.2
>
> Since the browsers are pointed to the proxy at 192.168.0.1, I thought
> that maybe once it comes from the squid box that maybe it is using the
> public IP from eth0 instead of the private from eth1? I don't know
> how all that works technically so I just removed the -s 192.168.0.0/16
> in case it was trying to come from the public side which is
> 1.1.1.0/24.
>
> As I said, not really sure if that is correct thinking or not, but now
> it works fine.
Hmm, nevermind. I'll retract that. I thought it was, but it isn't.
Still going back to the firewall. I give up. Thanks.
--
Scott Mayo
Mayo's Pioneer Seeds
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2014-02-25 18:12 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-27 19:22 Public IP to Private IP Scott Mayo
2014-01-27 19:36 ` Robby Workman
2014-01-27 20:08 ` Mike Wright
2014-01-27 20:46 ` Bob Reiber
2014-01-27 20:48 ` Ray Soucy
2014-01-27 21:01 ` Scott Mayo
2014-01-27 21:30 ` Ray Soucy
2014-02-02 15:45 ` Pascal Hambourg
2014-02-02 16:09 ` Mauricio Tavares
2014-02-02 16:36 ` Pascal Hambourg
2014-01-28 7:32 ` Rob Sterenborg (lists)
2014-02-24 18:22 ` Scott Mayo
2014-02-24 19:13 ` Scott Mayo
2014-02-24 21:56 ` Scott Mayo
2014-02-25 18:06 ` Scott Mayo
2014-02-25 18:12 ` Scott Mayo
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.