IPTables Prerouting


 
Thread Tools Search this Thread
Special Forums IP Networking IPTables Prerouting
# 1  
Old 09-04-2012
IPTables Prerouting

Hi ,

My route looks like below:
Code:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.253   192.168.1.210   255.255.255.255 UGH   0      0        0 eth2
203.6.21.111   0.0.0.0         255.255.255.252 U     0      0        0 eth0
192.168.3.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth2
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth2
0.0.0.0         203.6.21.112   0.0.0.0         UG    0      0        0 eth0



Observe LAN 192.168.1.253 which goes via 192.168.1.210

Now here is my prerouting rule

iptables -t nat -A PREROUTING -p tcp -i eth0 -d 203.6.21.111 --dport 8001 -j DNAT --to 192.168.1.104:80

When I hit url http://
203.6.21.111:8001 - it is not redirecting to mentioned ip and port.. I'm not sure what else am I missing here..

Code:
[root@lead ~]# ping 192.168.1.104
PING 192.168.1.104 (192.168.1.104) 56(84) bytes of data.
64 bytes from 192.168.1.104: icmp_seq=1 ttl=128 time=2.66 ms
64 bytes from 192.168.1.104: icmp_seq=2 ttl=128 time=0.725 ms

--- 192.168.1.104 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.725/1.693/2.661/0.968 ms
[root@lead ~]# traceroute 192.168.1.104
traceroute to 192.168.1.104 (192.168.1.104), 30 hops max, 40 byte packets
 1  192.168.1.104 (192.168.1.104)  3.060 ms  2.996 ms  2.965 ms

[root@lead ~]# telnet 192.168.1.104 80
Trying 192.168.1.104...
Connected to 192.168.1.104 (192.168.1.104).
Escape character is '^]'.
^]

Thanks
ashok


Last edited by ashokvpp; 09-04-2012 at 10:46 PM..
# 2  
Old 09-10-2012
Just reading the man page, but don't you need symmetrical rules to allow packets to flow both ways and make a tcp connection? Man Page for iptables (linux Section 8) - The UNIX and Linux Forums After your tcp syn packet gets there, the tcp syn ack has to have a path back.

Pre is for packets outgoing from inside-net, post is for packets incoming from outside-net, and output is for locally gen packets. For a firewall host, one seems to need reciprocal Pre and Post, and for a local only client firewall, output and post.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Ubuntu

iptables

Hi I need help with an iptables configuration, this is what I have server A Server B A and B are using different gateways i am sending port 22 from A to B, I see the packages coming in B but B is not sending the package to internet. please give me some examples. (0 Replies)
Discussion started by: lmartinez073
0 Replies

2. IP Networking

Debugging NAT / prerouting issues (iptables)

Hello, Recently I discovered an issue with packet routing in the latest Android releases (4.4+ KitKat & Lollipop). It seems that the problem Android specific, but essentially it comes from the Linux kernel. I already filed a bug report to Google. You can see the details by searching for... (0 Replies)
Discussion started by: Vladislav
0 Replies

3. IP Networking

Help with iptables

photo... (1 Reply)
Discussion started by: beerpong1
1 Replies

4. UNIX for Dummies Questions & Answers

Help with iptables

Hi, I just build a Linux server, I said yes to enable the firewall. I only choose SSH conneciton. When I check the iptables. I see all of this (see below). I want to reject every thing only allow SSH from subnet 192.168.1.xx. Can you advise, how to do. Chain RH-Firewall-1-INPUT (2... (2 Replies)
Discussion started by: samnyc
2 Replies

5. IP Networking

iptables NAT prerouting & postrouting

Good morning, I'm a newbie of iptables and as far as I've seen on tutorials on the Internet it seems that both prerouting and postrouting NAT chains are undergone both by a packet that goes from an internal LAN to the Internet and of a one that goes in the opposite direction (from the Internet to... (0 Replies)
Discussion started by: giac85
0 Replies

6. UNIX for Dummies Questions & Answers

help with iptables

Hi, On the IPTABLES, I did iptables --flush. I want to start fresh. Now I only want two things. Allow one ip address to this server. Allow port 443 as incoming from every where. Please advice how to do this. This is what I did so for. iptables -I INPUT -i eth0 -s 1.2.3.4 -j ACCEPT... (5 Replies)
Discussion started by: samnyc
5 Replies

7. IP Networking

iptables changes

Hello We have one linux machine in the office which happens to be an important firewall. I just know the basics and need to make one change Essentially it is forward mysql traffic to another internal machine. This is the original rule (forward to 192.20.0.17) which is working ... (0 Replies)
Discussion started by: rina5392
0 Replies

8. IP Networking

Iptables

What should be the iptables rule so that only the subnet 64.61.11.224/255.255.255.248 may access the mysql port 3306 (1 Reply)
Discussion started by: proactiveaditya
1 Replies

9. IP Networking

Iptables

Thanks in advance I have to remove ip_tables_name from /proc/net/... i was trying to do so and getting the following error cmd : rm ip_tables_names error : rm: remove regular empty file `ip_tables_names'? y rm: cannot remove `ip_tables_names': Operation not permitted (4 Replies)
Discussion started by: sudeepiit
4 Replies

10. IP Networking

IPtables

Hey guys, I have just started using IP tables and was wondering if anyone could direct me to any good online resources as I am totally new to this. Thanks. (1 Reply)
Discussion started by: 182x
1 Replies
Login or Register to Ask a Question