Find the answer to your Linux question:
Results 1 to 5 of 5
ok, the situation. i have the following scenario: ----------- |internet | ----------- | | | ------------ |Cablemodem| ------------ | | | |Blueyonder DHCP Assigned{eth1:} ------------ | gateway | ------------ |192.168.0.1{eth0} ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Guru sdousley's Avatar
    Join Date
    Feb 2004
    Posts
    1,790

    iptables port forwarding


    ok, the situation.

    i have the following scenario:
    -----------
    |internet |
    -----------
    |
    |
    |
    ------------
    |Cablemodem|
    ------------
    |
    |
    |
    |Blueyonder DHCP Assigned{eth1:}
    ------------
    | gateway |
    ------------
    |192.168.0.1{eth0}
    |
    |
    ------------
    | switch |
    ------------
    | | |
    | | |
    | | |192.168.0.9{eth0:}
    X X --------------
    | workstation|
    --------------
    |
    |
    |USB webcam {/dev/video0}
    now, i have setup an application called palantir that allows me to stream my webcam to the internet, and it uses port 3000, now what i need to do is forward requests on eth1, port 3000 of the gateway to my computer, how do i set this up using iptables?

    Hope the diagram helps in what i need to do.
    "I am not an alcoholic, alcoholics go to meetings"
    Registered Linux user = #372327

  2. #2
    Linux Enthusiast
    Join Date
    Feb 2005
    Location
    SE, Stockholm
    Posts
    512
    It should be something like this

    Code:
    iptables -A PREROUTING -i eth1 -p tcp -m tcp --dport 3000 -j DNAT --to-destination 192.168.1.9:3000
    iptables -A INPUT -i eth1 -p tcp -m tcp --dport 3000 -j ACCEPT

  3. #3
    Linux Guru sdousley's Avatar
    Join Date
    Feb 2004
    Posts
    1,790
    Quote Originally Posted by swemic
    It should be something like this

    Code:
    iptables -A PREROUTING -i eth1 -p tcp -m tcp --dport 3000 -j DNAT --to-destination 192.168.1.9:3000
    iptables -A INPUT -i eth1 -p tcp -m tcp --dport 3000 -j ACCEPT
    ok, the first line gives an error:
    jebediah:~ # iptables -A PREROUTING -i eth1 -p tcp -m tcp --dport 3000 -j DNAT --to-destination 192.168.0.9:3000
    iptables: No chain/target/match by that name
    "I am not an alcoholic, alcoholics go to meetings"
    Registered Linux user = #372327

  4. #4
    Just Joined!
    Join Date
    Apr 2005
    Posts
    1
    iptables -t nat -A PREROUTING -i eth1 -p tcp -m tcp --dport 3000 -j DNAT --to-destination 192.168.1.9:3000
    iptables -A INPUT -i eth1 -p tcp -m tcp --dport 3000 -j ACCEPT


    add -t nat

  5. #5
    Linux Enthusiast
    Join Date
    Feb 2005
    Location
    SE, Stockholm
    Posts
    512
    Yeah, I forgot that "-t nat" *sorry about that*

Posting Permissions

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