Article 5G816 Simple bash script to edit **sysctl**, what is wrong?

Simple bash script to edit **sysctl**, what is wrong?

by
hkjz
from LinuxQuestions.org on (#5G816)
Hey, i wanted to make a simple script to edit sysctl,
however i got problem,
what i suppose to make different?
thanks
=========
Script is:

Code:#!/bin/bash
#
# prevent SYN flood attacks in Linux

# sources
# https://meterpreter.org/prevent-syn-flood-attacks-in-linux/

SYSCTL=/etc/sysctl.conf

echo " "
echo " == START == "
echo " *opened /etc/sysctl.conf"

echo " "
echo " * 9 saved rules "

${SYSCTL} -w net.ipv4.tcp_syncookies=1
${SYSCTL} -w net.ipv4.tcp_max_syn_backlog=3072
${SYSCTL} -w net.ipv4.tcp_synack_retries=0
${SYSCTL} -w net.ipv4.tcp_syn_retries=0
${SYSCTL} -w net.ipv4.conf.all.send_redirects=0
${SYSCTL} -w net.ipv4.conf.all.accept_redirects=0
${SYSCTL} -w net.ipv4.conf.all.forwarding=0
${SYSCTL} -w net.ipv4.icmp_echo_ignore_broadcasts=1
${SYSCTL} -w net.ipv4.icmp_echo_ignore_all=1

echo " "
echo " == FINISH == "==========
problem is:

Code:$ sudo bash SYN_flood_YES

== START ==
*opened /etc/sysctl.conf

* 9 saved rules
SYN_flood_YES: line 16: /etc/sysctl.conf: Permission denied
SYN_flood_YES: line 17: /etc/sysctl.conf: Permission denied
SYN_flood_YES: line 18: /etc/sysctl.conf: Permission denied
SYN_flood_YES: line 19: /etc/sysctl.conf: Permission denied
SYN_flood_YES: line 20: /etc/sysctl.conf: Permission denied
SYN_flood_YES: line 21: /etc/sysctl.conf: Permission denied
SYN_flood_YES: line 22: /etc/sysctl.conf: Permission denied
SYN_flood_YES: line 23: /etc/sysctl.conf: Permission denied
SYN_flood_YES: line 24: /etc/sysctl.conf: Permission denied

== FINISH ==latest?d=yIl2AUoC8zA latest?i=wNgLPx6fpQk:cMo-4OXUxr0:F7zBnMy latest?i=wNgLPx6fpQk:cMo-4OXUxr0:V_sGLiP latest?d=qj6IDK7rITs latest?i=wNgLPx6fpQk:cMo-4OXUxr0:gIN9vFwwNgLPx6fpQk
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments