Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
share|improve this question
1  
I found the answer. I needed to $sudo -s –  01BTC10 Dec 20 '11 at 0:44
    
Please provide the solution as an answer and accept it as the right answer :) –  nitstorm Dec 20 '11 at 13:05
    
related: Redirect the output using sudo –  JonnyJD Aug 26 at 8:56

1 Answer 1

up vote 2 down vote accepted

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.