LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Iptables problem - unknown option "--dports" (https://www.linuxquestions.org/questions/linux-newbie-8/iptables-problem-unknown-option-dports-4175460160/)

Sorbitol 04-30-2013 10:29 AM

Iptables problem - unknown option "--dports"
 
Hello!

I am running an OpenVPN client on my Raspberry Pi, which is running Xbian, a variant of Debian. Currently all traffic goes through the VPN, but I'd like to set certain applications to use the regular network interface. After some googling it seemed the best solution was to use iptables.

I've been trying to set port 7000,6697 and 9999 to only use eth0 but iptables isn't cooperating. When I do:
Code:

sudo iptables -A PREROUTING -i eth0 -t mangle -p tcp --dports 7000,6697,9999 -j MARK --set-mark 1
All I get is
Code:

iptables v1.4.18: unknown option "--dports"
I've tried recompiling from the latest tarballs but there was no difference. Any ideas what I could do?

unSpawn 04-30-2013 11:05 AM

Load with "-m multiport" before using --dports"?

Sorbitol 04-30-2013 11:33 AM

Thank you, that worked! The next step from the stackoverflow answer I'm following is:
Code:

echo "201 eth1.out" >> /etc/iproute2/rt_tables
but when I do that bash says permission denied even if I run it as root. Can I just edit rt_tables manually with nano instead or is there another command?

unSpawn 04-30-2013 11:56 AM

Quote:

Originally Posted by Sorbitol (Post 4941992)
(..) when I do that bash says permission denied even if I run it as root. Can I just edit rt_tables manually with nano instead or is there another command?

Different questions different threads as far as I'm concerned. For me the command worked so the question isn't (or shouldn't be) what's the workaround but why it doesn't work. Does the file, or the directory it resides in, exist?
Is the file, or the directory it resides in, made immutable ('man lsattr')?
Else run
Code:

strace -v /bin/echo 201 eth1.out >> /etc/iproute2/rt_tables
as root.

Sorbitol 04-30-2013 12:48 PM

When I run lsattr rt_tables I get:
Code:

-------------e-- rt_tables
sudo strace -v /bin/echo 201 eth1.out >> /etc/iproute2/rt_tables gives me:
Code:

-bash: /etc/iproute2/rt_tables: Permission denied
Edit: I can edit it just fine with nano. Strange.
Edit2: I can run the command if I use sudo su to change to the root account. Just plain sudo doesn't work.

unSpawn 04-30-2013 01:57 PM

Indeed odd. No idea why though as you didn't run the strace command as root.

Sorbitol 04-30-2013 02:42 PM

I ran strace as root, the output is here if you'd like to take a look at it.

Meanwhile, I've done as instructed on stackoverflow and still cannot get specific ports to not go through the VPN. Iptables and iproute2 are quite difficult to understand for me. But I suppose that is for another thread, my original question has been answered. :)

unSpawn 04-30-2013 04:35 PM

Thanks for the strace, didn't help though, no errors I can find. Quite stumped as it ain't about extended attributes either...


All times are GMT -5. The time now is 07:17 AM.