如何在 Debian 中为此脚本创建一个初始化脚本 LSB 标头?

如何在 Debian 中为此脚本创建一个初始化脚本 LSB 标头?

我有下面的脚本,但是如何在 Debian 中为其创建 LSB 标头?我想放入我的 init.d 中。我知道对于 Fedora 来说是可以的,但是对于 Debian 来说我不知道​​。或者我在哪里以及如何放入rc.local

  #!/bin/sh

  # Variaveis
  LOIF="lo"
  LOIP="127.0.0.1/32"
  LOOPBACKIF="lo"
  LOOPBACKIP="127.0.0.1/32"


  INTIF="eth0"
  INTIP="192.3.1.2/32"
  REDEINT="192.3.1.0/24"

  EXTIF="eth1"
  EXTIP="192.168.1.8/32"
  UNIVERSO="0.0.0.0/0"
  PALTAS="1024:65535"
  IPTABLE="/sbin/iptables"
  LOGGING="-l"


  # Geral
  echo " - Desabilitando ataques de IP Spoofing."
  echo "2" > /proc/sys/net/ipv4/conf/all/rp_filter

  # Habilitando FORWARDing
  echo "1" > /proc/sys/net/ipv4/ip_forward

  # Kill Timestamps
  echo "0" > /proc/sys/net/ipv4/tcp_timestamps

  # Habilitando protecao a Cookie TCP SYN
  echo " - Habilitando protecao a Cookie TCP SYN."
  echo "1" > /proc/sys/net/ipv4/tcp_syncookies

  # Certifique que as configuracoes de diversos ICMP sanity estao presentes.
  echo " - Habilitando configuracoes de ICMP."

  # Desabilitando protecao a echo de broadcast ICMP.
  echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
  # Habilitando protecao a mensagem de "bad error"
  echo "1" > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses

  # Desabilitando redirecionamentos de ICMP
  echo "0" > /proc/sys/net/ipv4/conf/all/accept_redirects

  # Logar pacotes spoofed, roteados na origem ou redirecionados.
  echo " - Logar pacotes spoofed, roteados na origem ou redirecionados "
  echo "1" > /proc/sys/net/ipv4/conf/all/log_martians

  # Set out local port range
  echo "32768 61000" > /proc/sys/net/ipv4/ip_local_port_range

  # Reduce Dos'ing ability by reducing timeout
  echo "30" > /proc/sys/net/ipv4/tcp_fin_timeout
  echo "1800" > /proc/sys/net/ipv4/tcp_keepalive_time
  echo "0" > /proc/sys/net/ipv4/tcp_window_scaling
  echo "0" > /proc/sys/net/ipv4/tcp_sack

  # Carga dos Modulos
  /sbin/modprobe ip_tables
  /sbin/modprobe iptable_filter
  /sbin/modprobe ip_nat_ftp
  /sbin/modprobe iptable_nat
  /sbin/modprobe ip_conntrack
  /sbin/modprobe ip_conntrack_ftp
  #Regra para pacotes com defeito
  $IPTABLE -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
  $IPTABLE -A INPUT -m state --state INVALID -j DROP
  $IPTABLE -A FORWARD -m state --state INVALID -j DROP

  $IPTABLE -t nat -A POSTROUTING -s $REDEINT -d $UNIVERSO -o $EXTIF -j MASQUERADE  

答案1

您的文件头部需要有以下块:

### BEGIN INIT INFO
# Provides:          scriptname
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

请务必根据您的需求进行定制。

欲了解更多信息,请参阅Debian LSB 初始化脚本 wiki页。

相关内容