1

When I type: $ sudo echo 1 > /proc/sys/net/ipv3/ip_forward

I get: bash: /proc/sys/net/ipv3/ip_forward: No such file or directory

I can't mkdir any folder past /proc/sys/net nor can I move or create a file there.

I try to setup my box to IP forward before launching arpspoof

Thank's for your input!

EDIT:

Now with a variant I get:

$ sudo echo 1 > /proc/sys/net/ipv4/ip_forward
bash: /proc/sys/net/ipv4/ip_forward: Permission denied
2

1 Answer 1

3

1- Where your example says ipv3, it should probably read ipv4.

2- Here's one other way to accomplish this without using sudo -s:

echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward

Now, the explanation for this problem is as follows. The original command has this structure:

$ sudo echo 1 > /proc/sys/net/ipv4/ip_forward
^^^ Part 1 ^^   ^^^^  Part 2 ^^^^

Part 1 runs as sudo, BUT you're then trying to redirect output to a file. The redirection itself "runs" as an unprivileged user, that's why it has no permission to write to the file.

The solution I propose does the "echo" as an unprivileged user, but then pipes that to the "tee" command, which we run through sudo. Thus, tee will be run as root and will be able to write to the file.

Tee basically takes standard input and writes it to both a file and stdout. This is commonly used to write to a file while also getting the output on-screen. If you want to know more about tee, check the man page.

2
  • Thank's very much! I already knew the tee command but did not taught about using it this way.
    – 01BTC10
    Dec 20, 2011 at 17:36
  • Thanks, that's the right explanation of the underlying problem.
    – count0
    Dec 27, 2013 at 20:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .