Souci script shell

Résolu
Noel-barbu Messages postés 305 Statut Membre -  
Noel-barbu Messages postés 305 Statut Membre -
Bonjour,

Voilà j'ai un souci de script Shell auquel je n'ai vraiment aucune idée d'où ça peut venir
J'ai édité le scripte sous Windows avec Notepad +++ j'ai suivis quelque forum apparemment ça viendrais de l'encodage du coup j'ai repris le même scripte et je les coder sous Linux.

Voilà ce que cela me met

- Suppression des règles NetFilter : [OK]
- Politique de blocage générale : [OK]
- Interdiction ping : [OK]
iptables v1.4.21: Can't use -i with OUTPUT

Try 'iptables -h' or 'iptables --help' for more information.
- Autorisation Interface réseau : [OK]
- Paramètrage HTTP + HTTPS : [OK]
- Paramètrage DNS : [OK]
- Paramètrage FTP : [OK]
- Paramètrage SMTP : [OK]
- Paramètrage POP3 / POP3 SSL : [OK]
- Paramètrage IMAP : [OK]
iptables v1.4.21: Can't use -i with OUTPUT

Try 'iptables -h' or 'iptables --help' for more information.
iptables v1.4.21: Can't use -i with OUTPUT

Try 'iptables -h' or 'iptables --help' for more information.
- Autorisation SSH : [OK]

donc si quelqu'un à une idée.

3 réponses

  1. jee pee Messages postés 31892 Date d'inscription   Statut Modérateur Dernière intervention   9 984
     
    Bonjour, tu devrais mettre le script pour que quelqu'un puisse t'aider, pas seulement les messages d'erreur.

    cdlt
    0
    1. Noel-barbu Messages postés 305 Statut Membre 2
       
      ok pas de problème je le fais de suite

      #!/bin/sh
      #
      # ====== Variable ACCEPT / DROP ====== #
      #
      #
      # Autorisation Globale
      sortie=DROP
      entre=DROP
      forward=DROP
      #
      #
      # Ping ICMP
      ping=DROP
      #
      #
      # Interface
      interface_sortie=ACCEPT
      interface_entre=ACCEPT
      interface=wlan0
      #
      #
      # HTTP Apache
      http_sortie=DROP
      http_entre=DROP
      https_sortie=DROP
      https_entre=DROP
      #
      #
      # DNS Serveur
      dns_sortie=DROP
      dns_entre=DROP
      #
      #
      # FTP
      ftp_sortie=DROP
      ftp_entre=DROP
      #
      #
      # SMTP
      smtp_sortie=DROP
      smtp_entre=DROP
      #
      #
      # POP3
      pop3_sortie=DROP
      pop3_entre=DROP
      pop3ssl_sortie=DROP
      pop3ssl_entre=DROP
      #
      #
      # IMAP
      imap_sortie=DROP
      imap_entre=DROP
      #
      #
      # SSH
      ssh_sortie=ACCEPT
      ssh_entre=ACCEPT
      # ================================= #
      #
      #
      # Effacement de toute les régles de netfilter
      iptables -F
      iptables -X
      echo '- Suppression des règles NetFilter :  [OK]'
      #
      #
      # Politique par default, tout est interdit.
      iptables -P OUTPUT $sortie
      iptables -P INPUT $entre
      iptables -P FORWARD $forward
      echo '- Politique de blocage générale :  [OK]'
      #
      #
      # Blocage Ping
      iptables -t filter -A OUTPUT -p icmp -j $ping
      iptables -t filter -A INPUT -p icmp -j $ping
      echo '- Interdiction ping :  [OK]'
      #
      #
      # Autorisation Interface Carte réseau
      iptables -t filter -A OUTPUT -i $interface -j $interface_sortie
      iptables -t filter -A INPUT -i $interface -j $interface_entre
      echo '- Autorisation Interface réseau :  [OK]'
      #
      #
      # HTTP + HTTPS Entrée /  Sortie
      iptables -t filter -A OUTPUT -p tcp --dport 80 -j $http_sortie
      iptables -t filter -A OUTPUT -p tcp --dport 443 -j $https_sortie
      iptables -t filter -A INPUT -p tcp --dport 80 -j $http_entre
      iptables -t filter -A INPUT -p tcp --dport 443 -j $https_entre
      echo '- Paramètrage HTTP + HTTPS :  [OK]'
      #
      #
      # DNS
      iptables -t filter -A OUTPUT -p tcp --dport 53 -j $dns_sortie
      iptables -t filter -A OUTPUT -p udp --dport 53 -j $dns_sortie
      iptables -t filter -A INPUT -p tcp --dport 53 -j $dns_entre
      iptables -t filter -A INPUT -p udp --dport 53 -j $dns_entre
      echo '- Paramètrage DNS :  [OK]'
      #
      #
      # FTP
      iptables -t filter -A OUTPUT -p tcp --dport 21 -j $ftp_sortie
      iptables -t filter -A OUTPUT -p tcp --dport 20 -j $ftp_sortie
      iptables -t filter -A INPUT -p tcp --dport 20 -j $ftp_entre
      iptables -t filter -A INPUT -p tcp --dport 21 -j $ftp_entre
      echo '- Paramètrage FTP :  [OK]'
      #
      #
      # Mail SMTP 25
      iptables -t filter -A OUTPUT -p tcp --dport 25 -j $smtp_sortie
      iptables -t filter -A INPUT -p tcp --dport 25 -j $smtp_entre
      echo '- Paramètrage SMTP :  [OK]'
      #
      #
      # Mail POP3 110
      iptables -t filter -A OUTPUT -p tcp --dport 110 -j $pop3_sortie
      iptables -t filter -A INPUT -p tcp --dport 110 -j $pop3_entre
      iptables -t filter -A OUTPUT -p tcp --dport 995 -j $pop3ssl_sortie
      iptables -t filter -A INPUT -p tcp --dport 995 -j $pop3ssl_entre
      echo '- Paramètrage POP3 / POP3 SSL :  [OK]'
      #
      #
      # Mail IMAP 143
      iptables -t filter -A OUTPUT -p tcp --dport 143 -j $imap_sortie
      iptables -t filter -A INPUT -p tcp --dport 143 -j $imap_entre
      echo '- Paramètrage IMAP :  [OK]'
      #
      #
      # SSH
      iptables -t filter -A OUTPUT -i $interface -s 192.168.1.0/24 -p tcp --dport 5000 -j $ssh_sortie
      iptables -t filter -A INPUT  -i $interface -s 192.168.1.0/24 -p tcp --dport 5000 -j $ssh_entre
      iptables -t filter -A OUTPUT -i $interface -s 10.250.30.12 -p tcp --dport 5000 -j $ssh_sortie
      iptables -t filter -A INPUT  -i $interface -s 10.250.30.12 -p tcp --dport 5000 -j $ssh_entre
      echo '- Autorisation SSH :  [OK]'
      0
  2. jee pee Messages postés 31892 Date d'inscription   Statut Modérateur Dernière intervention   9 984
     
    Je n'ai aucune idée de la commande ou à quoi elle sert.

    Mais le message d'erreur est clair : iptables v1.4.21: Can't use -i with OUTPUT

    Sur une ligne de la commande iptables, tu ne peux pas utiliser le parametre OUTPUT avec le paramètre -i

    D'ailleurs que signifie -i , pas INPUT ??

    Taper iptables -h te donnera l'aide sur la commande

            Un étranger, c'est un ami qu'on n'a pas encore rencontré.
    0
  3. zipe31 Messages postés 34620 Date d'inscription   Statut Contributeur Dernière intervention   6 501
     
    Salut,

    Comme te l'a dit jee pee, c'est l'option
    -i
    qui pose problème, utilise l'option
    -o
    à la place.

    Extrait du man iptables :

           [!] -i, --in-interface name
    Name of an interface via which a packet was received (only for packets entering
    the INPUT, FORWARD and PREROUTING chains). When the "!" argument is used before
    the interface name, the sense is inverted. If the interface name ends in a "+",
    then any interface which begins with this name will match. If this option is
    omitted, any interface name will match.

    [!] -o, --out-interface name
    Name of an interface via which a packet is going to be sent (for packets entering
    the FORWARD, OUTPUT and POSTROUTING chains). When the "!" argument is used
    before the interface name, the sense is inverted. If the interface name ends in
    a "+", then any interface which begins with this name will match. If this option
    is omitted, any interface name will match.

    0
    1. Noel-barbu Messages postés 305 Statut Membre 2
       
      Effectivement il faillais utiliser l'option -o

      Merci beaucoup mon script fonctionne parfaitement
      0