Создал себе скрипт в init.d
#! /bin/sh
### BEGIN INIT INFO
# Provides: firewall
# Required-Start: $syslog $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Fill iptables rules
### END INIT INFO
ip=/sbin/iptables
LOCAL_IF=eth1
LOCAL_NET="192.168.1.0/24"
INET_IF=eth0
INET_IP=10.10.1.6/24
PATH=/sbin:/usr/sbin:/bin:/usr/bin
. /lib/init/vars.sh
. /lib/lsb/init-functions
do_start() {
$ip -A INPUT -p tcp --dport 4491 -j ACCEPT
$ip -P INPUT DROP
}
do_stop (){
$ip -F
$ip -t nat -F
}
case "$1" in
start)
do_start
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
do_stop
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac
Сделал его исполняемым дал права, дальше пишу: /etc/init.d/start выдает:
[....] Starting firewall (via systemctl): firewall.serviceJob for firewall.service failed because the control process exited with error code. See "systemctl status firewall.service" and "journalctl -xe" for details.
failed!
Пишу systemctl status firewall.service выдает:
● firewall.service - LSB: Fill iptables rules
Loaded: loaded (/etc/init.d/firewall; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2017-03-10 22:50:23 EET; 58s ago
Docs: man:systemd-sysv-generator(8)
Process: 2424 ExecStart=/etc/init.d/firewall start (code=exited, status=203/EXEC)
Mar 10 22:50:23 gateway-office systemd[1]: Starting LSB: Fill iptables rules...
Mar 10 22:50:23 gateway-office systemd[1]: firewall.service: Control process exited, code=exited status=203
Mar 10 22:50:23 gateway-office systemd[1]: Failed to start LSB: Fill iptables rules.
Mar 10 22:50:23 gateway-office systemd[1]: firewall.service: Unit entered failed state.
Mar 10 22:50:23 gateway-office systemd[1]: firewall.service: Failed with result 'exit-code'.
Пишу systemctl enable firewall.service выдает:
firewall.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install enable firewall
В инете ничего дельного нет, iptables переустанавливал. Ядро 4.4.0-66-generic. Версия iptables 1.6.0-2ubuntu3