Redirect port with iptables

Discussion in 'Linux Networking' started by Peter Penzov, Jun 24, 2014.

  1. Peter Penzov

    Peter Penzov New Member

    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    I have a dd-wrt router which I want to use for traffic redirection. In my case I have a VPS with Oracle which is listening on port 1521. I would like to access this server from my work but unfortunately port 1521 is blocked. I would like to use Oracle on port 25 from my work so I'm looking for a way to redirect traffic using my home router. So I need to configure the router to receive traffic from my laptop on port 25 and redirect this traffic to port 1521. Can you tell me what is the correct way to configure the iptables for this case?

  2. VitalkaDrug

    VitalkaDrug New Member

    Messages:
    22
    Likes Received:
    13
    Trophy Points:
    3
    Unfortunately I don't have info about custom iptables chains used in dd-wrt, but for my linux box I would have written the following rules:

    iptables -t nat -I PREROUTING -s LAPTOP_IP -p tcp --dport 25 -j DNAT --to-destination ORACLE_IP:1521

    It's enough for redirection. But I'm not sure it's enough to allow the packet transfer through your dd-wrt firewall. Possibly you should add a couple rules to allow transfer, like these:

    iptables -I FORWARD -s LAPTOP_IP -d ORACLE_IP -j ACCEPT
    iptables -I FORWARD -s ORACLE_IP -d LAPTOP_IP -j ACCEPT

Share This Page