D
D
Denis Sechin2017-03-10 23:53:59
System administration
Denis Sechin, 2017-03-10 23:53:59

Firewall fails on ubuntu-server-16?

I created a script in 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

I made it executable, gave it permissions, then I write: /etc/init.d/start issues:
[....] 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!

I write systemctl status firewall.service gives:
● 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'.

I write systemctl enable firewall.service gives out:
firewall.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install enable firewall

There is nothing sensible in the internet, I reinstalled iptables. Kernel 4.4.0-66-generic. iptables version 1.6.0-2ubuntu3

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Sechin, 2017-03-11
@tamogavk

It was just necessary to add a new service to systemd

S
sim3x, 2017-03-10
@sim3x

dev-notes.eu/2016/08/persistent-iptables-rules-in-...
init.d and sisv are gone

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question