I try for two or three hours , to exec a command with a script during the boot of fedora 23.
I see some tutorials with chkconfig but on my fedora, i have only systemctl, chkconfig is too old no ?.
I try to create a service but even when i exec : systemctl enable my_service
after the reboot , that does not exec my service. manually systemctl start my_service
works.
But more weird it's that the service starts because when i write systemctl list-unit-files –type=service
, i see my iptablesvpn.service enable . So really i don't understand why the command inside the script is not executed or maybe to soon, i don't know :/
So i trieda other solution which is to add a script in /etc/init.d/script.sh
with a chmod +x on it. But even that does not work.
I just want to restore iptables after the reboot. So i want something like: /sbin/iptables-restore /etc/firewall.rules
. After the boot, if i write this command in a terminal, that work and my vpn is happy but if don't write this command my vpn does not work.
So if you can help me to exec this command line , i will be happy because that seems to be very simple but it's not for me :/. Thank you
答案 0 :(得分:1)
这是我的进程,即使它没有在启动时使用脚本shell进行优化,也可以正常工作:
1)
iptables -F
iptables -P INPUT ACCEPT
iptables -F
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state -state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp -dport 22 -j ACCEPT
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -L -v
2)编辑/ etc / sysconfig / iptables-config并在Fedora上停止并重新启动关于iptables保存选项的“是”而不是“否”
3)在/etc/rc.d/rc.local中创建一个脚本shell,我写service iptables restart
并且它很好:)
你在这个过程中看到一些无用或奇怪的东西?