* how to access port forwarded server through internet ?
@ 2011-03-15 12:29 J. Bakshi
2011-03-15 13:16 ` Remzi AKYÜZ
2011-03-15 14:16 ` Pandu Poluan
0 siblings, 2 replies; 6+ messages in thread
From: J. Bakshi @ 2011-03-15 12:29 UTC (permalink / raw)
To: netfilter
Dear list,
Here is a port forwarding issue. I have a linux router which have two NIC; one facing WAN and the other facing LAN. IP forwarding is active and this box is working as a gateway. This box has LAN IP 192.168.1.1
There is another box (webserver) 192.168.1.2 within the internal network and the router box has port forwarding to access the webserver.
```````````````````````````
iptables -A INPUT -p tcp -m tcp --dport 81 -j ACCEPT
iptables -A PREROUTING -t nat -i ${LAN_IFACE} -p tcp --dport 81 -j DNAT --to 192.168.1.2:8080
iptables -A FORWARD -p tcp -m state --state NEW --dport 81 -i ${LAN_IFACE} -j ACCEPT
````````````````````````````
So within LAN I can access the 192.168.1.2 web server through 192.168.1.1:81 as port forwarding is there. But I can not access the same through internet. If I point at <domain-name>:81 throught internet ; the browser simply reports it can't connect to the service; though the other services running at that very server are quite accessible through internet. Have I missed something in my firewall rule ? Could anyone give any clue please ?
Thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: how to access port forwarded server through internet ?
2011-03-15 12:29 how to access port forwarded server through internet ? J. Bakshi
@ 2011-03-15 13:16 ` Remzi AKYÜZ
2011-03-15 13:52 ` J. Bakshi
2011-03-15 14:16 ` Pandu Poluan
1 sibling, 1 reply; 6+ messages in thread
From: Remzi AKYÜZ @ 2011-03-15 13:16 UTC (permalink / raw)
To: J. Bakshi; +Cc: netfilter
Hello,
forwarding is enable?
can you try this;
#sysctl -w net.ipv4.ip_forward=1
#iptables -A FORWARD -p tcp -m state --state NEW,ESTABLISHED --dport 81
-i ${LAN_IFACE} -j ACCEPT
On 03/15/2011 02:29 PM, J. Bakshi wrote:
> Dear list,
>
> Here is a port forwarding issue. I have a linux router which have two NIC; one facing WAN and the other facing LAN. IP forwarding is active and this box is working as a gateway. This box has LAN IP 192.168.1.1
>
> There is another box (webserver) 192.168.1.2 within the internal network and the router box has port forwarding to access the webserver.
>
> ```````````````````````````
> iptables -A INPUT -p tcp -m tcp --dport 81 -j ACCEPT
> iptables -A PREROUTING -t nat -i ${LAN_IFACE} -p tcp --dport 81 -j DNAT --to 192.168.1.2:8080
> iptables -A FORWARD -p tcp -m state --state NEW --dport 81 -i ${LAN_IFACE} -j ACCEPT
> ````````````````````````````
>
> So within LAN I can access the 192.168.1.2 web server through 192.168.1.1:81 as port forwarding is there. But I can not access the same through internet. If I point at<domain-name>:81 throught internet ; the browser simply reports it can't connect to the service; though the other services running at that very server are quite accessible through internet. Have I missed something in my firewall rule ? Could anyone give any clue please ?
>
> Thanks
> --
> 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] 6+ messages in thread
* Re: how to access port forwarded server through internet ?
2011-03-15 13:16 ` Remzi AKYÜZ
@ 2011-03-15 13:52 ` J. Bakshi
2011-03-16 7:20 ` J. Bakshi
0 siblings, 1 reply; 6+ messages in thread
From: J. Bakshi @ 2011-03-15 13:52 UTC (permalink / raw)
To: Remzi AKYÜZ; +Cc: netfilter
Hello Remzi,
Thanks for your kind response. Yes the forwarding is enable as I have it in my script
`````````````````
echo 1 > /proc/sys/net/ipv4/ip_forward
`````````````````````
But no luck :-( here is the modified rule
iptables -A INPUT -p tcp -m tcp --dport 81 -j ACCEPT
iptables -A PREROUTING -t nat -i ${LAN_IFACE} -p tcp --dport 81 -j DNAT --to 192.168.1.2:8080
iptables -A FORWARD -p tcp -m state --state NEW,ESTABLISHED --dport 81 -i ${LAN_IFACE} -j ACCEPT
On Tue, 15 Mar 2011 15:16:18 +0200
Remzi AKYÜZ <linuxliste@gmail.com> wrote:
> Hello,
> forwarding is enable?
> can you try this;
>
> #sysctl -w net.ipv4.ip_forward=1
> #iptables -A FORWARD -p tcp -m state --state NEW,ESTABLISHED --dport 81
> -i ${LAN_IFACE} -j ACCEPT
>
>
> On 03/15/2011 02:29 PM, J. Bakshi wrote:
> > Dear list,
> >
> > Here is a port forwarding issue. I have a linux router which have two NIC; one facing WAN and the other facing LAN. IP forwarding is active and this box is working as a gateway. This box has LAN IP 192.168.1.1
> >
> > There is another box (webserver) 192.168.1.2 within the internal network and the router box has port forwarding to access the webserver.
> >
> > ```````````````````````````
> > iptables -A INPUT -p tcp -m tcp --dport 81 -j ACCEPT
> > iptables -A PREROUTING -t nat -i ${LAN_IFACE} -p tcp --dport 81 -j DNAT --to 192.168.1.2:8080
> > iptables -A FORWARD -p tcp -m state --state NEW --dport 81 -i ${LAN_IFACE} -j ACCEPT
> > ````````````````````````````
> >
> > So within LAN I can access the 192.168.1.2 web server through 192.168.1.1:81 as port forwarding is there. But I can not access the same through internet. If I point at<domain-name>:81 throught internet ; the browser simply reports it can't connect to the service; though the other services running at that very server are quite accessible through internet. Have I missed something in my firewall rule ? Could anyone give any clue please ?
> >
> > Thanks
> > --
> > 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] 6+ messages in thread
* Re: how to access port forwarded server through internet ?
2011-03-15 12:29 how to access port forwarded server through internet ? J. Bakshi
2011-03-15 13:16 ` Remzi AKYÜZ
@ 2011-03-15 14:16 ` Pandu Poluan
1 sibling, 0 replies; 6+ messages in thread
From: Pandu Poluan @ 2011-03-15 14:16 UTC (permalink / raw)
To: J. Bakshi; +Cc: netfilter
My previous email was not sent to the list >_<
My answer is below.
On Tue, Mar 15, 2011 at 19:29, J. Bakshi <joydeep@infoservices.in> wrote:
> Dear list,
>
> Here is a port forwarding issue. I have a linux router which have two NIC; one facing WAN and the other facing LAN. IP forwarding is active and this box is working as a gateway. This box has LAN IP 192.168.1.1
>
> There is another box (webserver) 192.168.1.2 within the internal network and the router box has port forwarding to access the webserver.
>
> ```````````````````````````
> iptables -A INPUT -p tcp -m tcp --dport 81 -j ACCEPT
> iptables -A PREROUTING -t nat -i ${LAN_IFACE} -p tcp --dport 81 -j DNAT --to 192.168.1.2:8080
> iptables -A FORWARD -p tcp -m state --state NEW --dport 81 -i ${LAN_IFACE} -j ACCEPT
> ````````````````````````````
>
> So within LAN I can access the 192.168.1.2 web server through 192.168.1.1:81 as port forwarding is there. But I can not access the same through internet. If I point at <domain-name>:81 throught internet ; the browser simply reports it can't connect to the service; though the other services running at that very server are quite accessible through internet. Have I missed something in my firewall rule ? Could anyone give any clue please ?
>
> Thanks
> --
You need another iptables rules for the WAN_IFACE
iptables -A PREROUTING -t nat -i ${WAN_IFACE} -p tcp --dport 81 -j
DNAT --to 192.168.1.2:8080
You can combine this new rule with the old rule by dropping the -i
selector. I.e. :
iptables -A PREROUTING -t nat -p tcp --dport 81 -j DNAT --to 192.168.1.2:8080
Next, also add a proper FORWARD rule, since the FORWARD rule will be
processed after NAT takes place:
iptables -A FORWARD -d 192.168.1.2 -p tcp --dport 8080 -j ACCEPT
This rule allows forwarding to the webserver (192.168.1.2) port 8080,
no matter the incoming interface, be it WAN_IFACE or LAN_IFACE. No
need to match the state here.
Finally, remember that since the packets do not actually end up in the
firewall box, you don't need the -A INPUT rule there. It never gets
matched.
Rgds,
--
Pandu E Poluan
~ IT Optimizer ~
Visit my Blog: http://pepoluan.posterous.com
Google Talk: pepoluan
Y! messenger: pepoluan
MSN / Live: pepoluan@hotmail.com (do not send email here)
Skype: pepoluan
More on me: My LinkedIn Account My Facebook Account
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: how to access port forwarded server through internet ?
2011-03-15 13:52 ` J. Bakshi
@ 2011-03-16 7:20 ` J. Bakshi
2011-03-16 7:33 ` Remzi AKYÜZ
0 siblings, 1 reply; 6+ messages in thread
From: J. Bakshi @ 2011-03-16 7:20 UTC (permalink / raw)
To: Remzi AKYÜZ; +Cc: netfilter
Any clue please ?
On Tue, 15 Mar 2011 19:22:01 +0530
"J. Bakshi" <joydeep@infoservices.in> wrote:
> Hello Remzi,
>
> Thanks for your kind response. Yes the forwarding is enable as I have it in my script
>
> `````````````````
> echo 1 > /proc/sys/net/ipv4/ip_forward
> `````````````````````
>
> But no luck :-( here is the modified rule
>
> iptables -A INPUT -p tcp -m tcp --dport 81 -j ACCEPT
> iptables -A PREROUTING -t nat -i ${LAN_IFACE} -p tcp --dport 81 -j DNAT --to 192.168.1.2:8080
> iptables -A FORWARD -p tcp -m state --state NEW,ESTABLISHED --dport 81 -i ${LAN_IFACE} -j ACCEPT
>
>
> On Tue, 15 Mar 2011 15:16:18 +0200
> Remzi AKYÜZ <linuxliste@gmail.com> wrote:
>
> > Hello,
> > forwarding is enable?
> > can you try this;
> >
> > #sysctl -w net.ipv4.ip_forward=1
> > #iptables -A FORWARD -p tcp -m state --state NEW,ESTABLISHED --dport 81
> > -i ${LAN_IFACE} -j ACCEPT
> >
> >
> > On 03/15/2011 02:29 PM, J. Bakshi wrote:
> > > Dear list,
> > >
> > > Here is a port forwarding issue. I have a linux router which have two NIC; one facing WAN and the other facing LAN. IP forwarding is active and this box is working as a gateway. This box has LAN IP 192.168.1.1
> > >
> > > There is another box (webserver) 192.168.1.2 within the internal network and the router box has port forwarding to access the webserver.
> > >
> > > ```````````````````````````
> > > iptables -A INPUT -p tcp -m tcp --dport 81 -j ACCEPT
> > > iptables -A PREROUTING -t nat -i ${LAN_IFACE} -p tcp --dport 81 -j DNAT --to 192.168.1.2:8080
> > > iptables -A FORWARD -p tcp -m state --state NEW --dport 81 -i ${LAN_IFACE} -j ACCEPT
> > > ````````````````````````````
> > >
> > > So within LAN I can access the 192.168.1.2 web server through 192.168.1.1:81 as port forwarding is there. But I can not access the same through internet. If I point at<domain-name>:81 throught internet ; the browser simply reports it can't connect to the service; though the other services running at that very server are quite accessible through internet. Have I missed something in my firewall rule ? Could anyone give any clue please ?
> > >
> > > Thanks
> > > --
> > > 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
> >
>
> --
> 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] 6+ messages in thread
* Re: how to access port forwarded server through internet ?
2011-03-16 7:20 ` J. Bakshi
@ 2011-03-16 7:33 ` Remzi AKYÜZ
0 siblings, 0 replies; 6+ messages in thread
From: Remzi AKYÜZ @ 2011-03-16 7:33 UTC (permalink / raw)
To: J. Bakshi; +Cc: netfilter
Bakshi;
input interface maybe invalid.
can you try this;
iptables -t nat -I PREROUTING -i wan_intarface -p tcp --dport 81 -j
DNAT --to 192.168.1.2:8080
iptables -A FORWARD -p tcp -m state --state NEW,ESTABLISHED --dport 81 -i wan_intarface -j ACCEPT
if this is failure, can you send yours active iptables rules ? (iptables-save> ipt_gw.txt )
On 03/16/2011 09:20 AM, J. Bakshi wrote:
> Any clue please ?
>
>
> On Tue, 15 Mar 2011 19:22:01 +0530
> "J. Bakshi"<joydeep@infoservices.in> wrote:
>
>> Hello Remzi,
>>
>> Thanks for your kind response. Yes the forwarding is enable as I have it in my script
>>
>> `````````````````
>> echo 1> /proc/sys/net/ipv4/ip_forward
>> `````````````````````
>>
>> But no luck :-( here is the modified rule
>>
>> iptables -A INPUT -p tcp -m tcp --dport 81 -j ACCEPT
>> iptables -A PREROUTING -t nat -i ${LAN_IFACE} -p tcp --dport 81 -j DNAT --to 192.168.1.2:8080
>> iptables -A FORWARD -p tcp -m state --state NEW,ESTABLISHED --dport 81 -i ${LAN_IFACE} -j ACCEPT
>>
>>
>> On Tue, 15 Mar 2011 15:16:18 +0200
>> Remzi AKYÜZ<linuxliste@gmail.com> wrote:
>>
>>> Hello,
>>> forwarding is enable?
>>> can you try this;
>>>
>>> #sysctl -w net.ipv4.ip_forward=1
>>> #iptables -A FORWARD -p tcp -m state --state NEW,ESTABLISHED --dport 81
>>> -i ${LAN_IFACE} -j ACCEPT
>>>
>>>
>>> On 03/15/2011 02:29 PM, J. Bakshi wrote:
>>>> Dear list,
>>>>
>>>> Here is a port forwarding issue. I have a linux router which have two NIC; one facing WAN and the other facing LAN. IP forwarding is active and this box is working as a gateway. This box has LAN IP 192.168.1.1
>>>>
>>>> There is another box (webserver) 192.168.1.2 within the internal network and the router box has port forwarding to access the webserver.
>>>>
>>>> ```````````````````````````
>>>> iptables -A INPUT -p tcp -m tcp --dport 81 -j ACCEPT
>>>> iptables -A PREROUTING -t nat -i ${LAN_IFACE} -p tcp --dport 81 -j DNAT --to 192.168.1.2:8080
>>>> iptables -A FORWARD -p tcp -m state --state NEW --dport 81 -i ${LAN_IFACE} -j ACCEPT
>>>> ````````````````````````````
>>>>
>>>> So within LAN I can access the 192.168.1.2 web server through 192.168.1.1:81 as port forwarding is there. But I can not access the same through internet. If I point at<domain-name>:81 throught internet ; the browser simply reports it can't connect to the service; though the other services running at that very server are quite accessible through internet. Have I missed something in my firewall rule ? Could anyone give any clue please ?
>>>>
>>>> Thanks
>>>> --
>>>> 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
>> --
>> 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] 6+ messages in thread
end of thread, other threads:[~2011-03-16 7:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-15 12:29 how to access port forwarded server through internet ? J. Bakshi
2011-03-15 13:16 ` Remzi AKYÜZ
2011-03-15 13:52 ` J. Bakshi
2011-03-16 7:20 ` J. Bakshi
2011-03-16 7:33 ` Remzi AKYÜZ
2011-03-15 14:16 ` Pandu Poluan
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.