Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.
$ sudo echo 1 >/proc/sys/net/ipv4/ip_forward 
bash: /proc/sys/net/ipv4/ip_forward: Permission denied

then I try to get write privilege, also failed.

$ sudo chmod a+wx /proc/sys/net/ipv4/ip_forward 
chmod: changing permissions of `/proc/sys/net/ipv4/ip_forward': Operation not permitted

what is wrong?

share|improve this question
should use $ sudo bash -c "echo 1 >/proc/sys/net/ipv4/ip_forward" – Victor S Aug 15 '13 at 14:43
related: Redirect the output using sudo – JonnyJD Aug 26 '14 at 8:53

2 Answers 2

You are trying to change the kernel values. Be sure of what you are doing.

Okay here is how you can change the value of ip_forward with root privilege (sudo -i)

  • First check the value of ip_forward using command: sysctl -a | grep ip_forward
  • Now using sysctl -w <parameter=value> you change the value of ip_forward:
    • sysctl -w ip_forward=1
  • Make these changes to reflect in kernel using: sysctl -p
  • Do the first step once again to check the values.

I recommend you to go through the man page of sysctl

share|improve this answer

Edit file /etc/sysctl.conf and edit this section:

#net.ipv4.ip_forward = 0


net.ipv4.ip_forward = 1 (remove # sign)

then type command: sysctl -p
Last, reboot your system.

share|improve this answer

Your Answer


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.