-2

I`m following along this post :

https://vpsboard.com/topic/4095-ipsecl2tp-vpn-on-ubuntu-1404/

in order to setup VPN Server in Ubunto, however when i come to this command :

for vpn in /proc/sys/net/ipv4/conf/*; do echo 0 > $vpn/accept_redirects; echo 0 > $vpn/send_redirects; done

I get Permission Denied, also i`m running the command using sudo!

i know sudo doesnt work with redirects but i dont know how to rewrite this command in order to execute it using su -c

Stacker
  • 123
  • 5

2 Answers2

2

You can run it as root after by

 sudo su -
 for vpn in /proc/sys/net/ipv4/conf/*; do echo 0 > $vpn/accept_redirects; echo 0 > $vpn/send_redirects; done

or with sudo as

sudo /bin/bash -c "for vpn in /proc/sys/net/ipv4/conf/*; do echo 0 > $vpn/accept_redirects; echo 0 > $vpn/send_redirects; done"
Stone
  • 7,011
  • 1
  • 21
  • 33
  • still gives me /bin/bash: /proc/sys/net/ipv4/conf/lo/send_redirects: Permission denied – Stacker Sep 16 '14 at 15:30
  • also it gives me gt: error: neither tool nor script specified; option -help lists possible tools – Stacker Sep 16 '14 at 15:31
  • 2
    Be careful. The command is crap because the author of the original post didn't noticed that `>` got replaced by the HTML `>` – Sven Sep 16 '14 at 15:31
1

You can use sudo bash -c to make it work:

 for vpn in /proc/sys/net/ipv4/conf/*; do 
   sudo bash -c 'echo 0 > $vpn/accept_redirects; echo 0 > $vpn/send_redirects'
  done
ThoriumBR
  • 5,302
  • 2
  • 24
  • 34