Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
Due to network maintenance being performed by our provider, LQ will be down starting at 05:01 AM UTC. The exact duration of the downtime isn't currently known. We apologize for the inconvenience.
|
 |
03-01-2013, 10:22 PM
|
#1
|
|
Member
Registered: Oct 2012
Posts: 30
Rep: 
|
IPTables routing internal requests
So I have a front end firewall using IP tables, it handles all requests coming in and talks down to the other boxes.
However I can not hit ports on my internal network that i can from the outside network for instance port 25 or 80.
Setup :
p3p1 - publicIP
p3p2 - 10.1.1.1
when do something like.
telnet MYpublicDomain.com 80
from an internal box i get connection refused.
here are my IPtables
[root@abby ~]# iptables -t nat -L -v -n
Chain PREROUTING (policy ACCEPT 1190 packets, 110K bytes)
pkts bytes target prot opt in out source destination
248 12896 DNAT tcp -- p3p1 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:443 to:10.1.1.10
9 476 DNAT tcp -- p3p1 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 to:10.1.1.10
0 0 DNAT tcp -- p3p1 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:21 to:10.1.1.10
23 1380 DNAT tcp -- p3p1 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:25 to:10.1.1.11
0 0 DNAT tcp -- p3p1 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:110 to:10.1.1.11
19 1140 DNAT tcp -- p3p1 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:143 to:10.1.1.11
0 0 DNAT tcp -- p3p1 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:2222 to:10.1.1.10
Chain INPUT (policy ACCEPT 808 packets, 55937 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 1843 packets, 128K bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 1767 packets, 118K bytes)
pkts bytes target prot opt in out source destination
738 81101 MASQUERADE all -- * p3p1 0.0.0.0/0 0.0.0.0/0
Not sure what I am missing here
tried to do this
iptables -t nat -A PREROUTING -i p3p2 -p tcp -d PublicIP --dport 80 -j DNAT --to-destination 10.1.1.10
But the connection just hangs i can see it hit iptables but than it dies. Also i still get connection refused from the firewall box directly. Any help would be awesome i am lost on this.
thank you!
|
|
|
|
03-02-2013, 12:07 AM
|
#2
|
|
Member
Registered: Feb 2003
Posts: 964
Rep:
|
Connections have multiple aspects.
A) a destination, like an IP address
B) a route, which is independent of any filtering.
C) a firewall which allows (or not) traffic to flow.
Most troubleshooting involves bypassing C) which isn't always a wise choice, but in some cases may be the only choice. Otherwise.
# ifconfig -a
# route -n
# iptables-save
# ebtables -t nat -L
Or whatever applies.
|
|
|
|
03-02-2013, 10:09 AM
|
#3
|
|
Member
Registered: Aug 2012
Distribution: Debian, CentOS
Posts: 71
Rep: 
|
iptables -t nat -A PREROUTING -i p3p2 -p tcp -d PublicIP --dport 80 -j DNAT --to-destination 10.1.1.10
in the above rule, u are specifying the input interface "-i p3p2" which i assume is the public interface. Hence you are able to access port 80 only from the public interface not the lan interface.
So to get access from the internal network, either do not specify the input interface "-i" or add another rule specifying the LAN interface.
|
|
|
|
03-02-2013, 07:37 PM
|
#4
|
|
Member
Registered: Oct 2012
Posts: 30
Original Poster
Rep: 
|
Quote:
Originally Posted by hamlindsza
iptables -t nat -A PREROUTING -i p3p2 -p tcp -d PublicIP --dport 80 -j DNAT --to-destination 10.1.1.10
in the above rule, u are specifying the input interface "-i p3p2" which i assume is the public interface. Hence you are able to access port 80 only from the public interface not the lan interface.
So to get access from the internal network, either do not specify the input interface "-i" or add another rule specifying the LAN interface.
|
See that's the weird part the p3p2 interface is the internal interface. What you saying is basically an any interface rule on that port and see what happens?
|
|
|
|
03-02-2013, 10:29 PM
|
#5
|
|
Member
Registered: Aug 2012
Distribution: Debian, CentOS
Posts: 71
Rep: 
|
Quote:
Originally Posted by SernOne
See that's the weird part the p3p2 interface is the internal interface. What you saying is basically an any interface rule on that port and see what happens?
|
Hmmm...Try adding a rule without specifying the interface, but specify the public ip.
Code:
iptables -t nat -I PREROUTING -p tcp -d PublicIP --dport 80 -j DNAT --to-destination 10.1.1.10:80
|
|
|
|
03-05-2013, 03:04 PM
|
#6
|
|
LQ Newbie
Registered: Mar 2013
Posts: 3
Rep: 
|
Hi Sernone,
This is what I believe is happening:
1) From within your network, you try to access your public IP on port 80.
2) Your latest DNAT rule on PREROUTING should work correctly : iptables -t nat -A PREROUTING -i p3p2 -p tcp -d PublicIP --dport 80 -j DNAT --to-destination 10.1.1.10
3) Now, you haven't shown us your FORWARD rules (iptables -vnL FORWARD) - but you will be forwarding from your p3p2 to p3p2 and back again, so you need something like this:
iptables -I FORWARD -i p3p2 -o p3p2 -j ACCEPT
4) This will allow your packets to hit the router and be forwarded back to 10.1.1.10 on your internal network.
5) However, assuming the IP address of your client machine is on that same network (10.1.1.0/24), you will have a small problem - ie, the web on 10.1.1.10 will receive your packets and answer directly to you (as it sees you are on the same network). Your machine will see packets arrive from 10.1.1.10 without the SYN bit set as if they were part of an existing connection and silently ignore them.
6) What you have to do is is SNAT on your router - iptables -t nat -A POSTROUTING -o p3p2 -j MASQUERADE
Thus 10.1.1.10 will always send responses back the way they arrived.
Hope this helps.
|
|
|
|
03-05-2013, 05:16 PM
|
#7
|
|
LQ Newbie
Registered: Mar 2013
Posts: 3
Rep: 
|
Just as an after thought, it's worth noting that if you put a MASQUERADE or SNAT rule on your internal interface without further qualification, all the log entries on your apache server will appear to come from your router; not very useful, I guess.
You could just change the MASQ rule I mentioned in the previous post as follows:
iptables -t nat -A POSTROUTING -o p3p2 -s 10.1.1.0/24 -j MASQUERADE
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:43 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|