Find the answer to your Linux question:
Results 1 to 3 of 3
I want to redirect traffic from one port to another port on the same machine. ive done iptables -t nat -A PREROUTING -i eth0 tcp --dport 28080 -j REDIRECT --to-port ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2008
    Posts
    2

    Port redirection on same machine


    I want to redirect traffic from one port to another port on the same machine.

    ive done iptables -t nat -A PREROUTING -i eth0 tcp --dport 28080 -j REDIRECT --to-port 80 .... just as a test (ive used a basic apache for test purposes, it will be with a different service later on) when I telnet to port 28080 on localhost, it refuses the connection but port 80 accepts a connection.

    robbie@r220-....-.....:~$ sudo iptables -t nat -nv -L
    Chain PREROUTING (policy ACCEPT 19890 packets, 1530K bytes)
    pkts bytes target prot opt in out source destination
    0 0 REDIRECT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:18080 redir ports 80
    0 0 REDIRECT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:28080 redir ports 80

  2. #2
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,677
    Quote Originally Posted by AussieGuySyd View Post
    I want to redirect traffic from one port to another port on the same machine.

    ive done
    iptables -t nat -A PREROUTING -i eth0 tcp --dport 28080 -j REDIRECT --to-port 80
    This rule only redirects packets that are coming in on the eth0 interface thus anything on the local interface is ignored by this rule.

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

  3. #3
    Just Joined!
    Join Date
    Jul 2009
    Posts
    1
    anyway to get this to work with the local interface? Any hack will do. I need to intercept an outgoing connection from the localhost.

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •