TransWikia.com

Trouble setting ports for forwarding

Unix & Linux Asked by KekeArifZZZ on December 12, 2021

I am on ubuntu and trying to add the following rule
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp — dport 80 -j REDIRECT — to-port 3000

At first I get the error Bad argument - So I guess it’s -to-port missing a trailing hyphen and change it to this:

sudo iptables -A PREROUTING -t nat -i eth0 -p tcp — dport 80 -j REDIRECT —-to-port 3000 I then get the same error. I guess this is related to the dport so I change the command to this:

sudo iptables -A PREROUTING -t nat -i eth0 -p tcp —-dport 80 -j REDIRECT —-to-port 3000

And now I get the error Bad argument —-dport. Not sure where to go from here. Any ideas on what I might be doing wrong and how I can fix this?

One Answer

If that's the exact line you are using, you are using two different dashes. The first is hex 97, Em Dash, and the second is hex 2d, dash, the minus sign. Re-do the line like this, using, dash, the minus sign.

sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000

Answered by John on December 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP