iptables port mapping ANY:95 to originalIP:80

Posted on 2005-04-30
Last Modified: 2010-03-18
I'm using my linux box as a router and I have an application that is make all the request in port 95.
I need to make an iptables rule that will change the original port of any destination ip addres to 80.
I know how to do it for a specific destination ip but I could not find the way to do it for any destination ip.

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 95 -j DNAT --to is the Google ip, but I need the rule to work for any ip. Something like:

iptables -t nat -A PREROUTING -i eth0 -p tcp -d ANY --dport 95 -j DNAT --to ANY:80

I know that it is possible to do in checkpoint firewall but it is a little expensive...
Question by:e_berg
    LVL 14

    Expert Comment

    i have this in my iptables

    iptables -t nat -A PREROUTING  -p tcp -d  --dport 81 -j DNAT  --to
    iptables -t nat -A PREROUTING  -p tcp -d  --dport 82 -j DNAT  --to

    Author Comment

    This is not what I need.
    I need to make something more generic.
    Not for a specifics ip.
    LVL 14

    Expert Comment

    replace -d for

    -d 0/0

    Author Comment

    This will not work.
    I found it.  It mast be:
    iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 95 -j DNAT --to-destination :80
    LVL 25

    Expert Comment

    No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
    I will leave the following recommendation for this question in the Cleanup topic area:

    Any objections should be posted here in the next 4 days. After that time, the question will be closed.

    EE Cleanup Volunteer

    Accepted Solution

    PAQed with points refunded (250)

    Community Support Moderator

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
    Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now