Answer the question
In order to leave comments, you need to log in
Why is the CRON script not running on boot?
Good afternoon. The script does not work in the cron at the start of the computer
Cron edited from the root
Line from the cron. Only the command echo
@reboot /root/firewall.sh > /root/firewall.log gets into the log file
Here is the script
#!/bin/bash
#sleep 60
sleep 30
echo 'Firewall script'
systemctl disable ufw;
systemctl stop ufw;
iptables -A INPUT -i lo -j ACCEPT;
iptables -A INPUT -p icmp --icmp-type 0 -j ACCEPT;
iptables -A INPUT -p icmp --icmp-type 3 -j ACCEPT;
iptables -A INPUT -p icmp --icmp-type 4 -j ACCEPT;
iptables -A INPUT -p icmp --icmp-type 11 -j ACCEPT;
iptables -A INPUT -p icmp --icmp-type 12 -j ACCEPT;
iptables -A INPUT -p tcp -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT;
iptables -A INPUT -s 188.242.*.* -p tcp --dport 22 -j ACCEPT;
iptables -A INPUT -p tcp --dport 10000 -j ACCEPT;
iptables -A INPUT -i tun+ -j ACCEPT;
iptables -A INPUT -i tap+ -j ACCEPT;
iptables -A INPUT -j DROP;
iptables -A OUTPUT -j ACCEPT;
Answer the question
In order to leave comments, you need to log in
Cron by default does not know the path to directories with programs.
Specify full paths to systemctl and iptables.
Add to the beginning of the script set -x
and it will hit not onlyecho
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question