iptables, ssh ed iplist/ipblock

Sicurezza del sistema: firewall, antispam, antivirus, ssh, patch, bug, eccetera.
Scrivi risposta
erpomata
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 315
Iscrizione: venerdì 16 maggio 2008, 18:58

iptables, ssh ed iplist/ipblock

Messaggio da erpomata »

Fino a Lunedì avevo configurato la mia macchina per poter accettare richieste di accesso da internet su ssh.
Lunedì decido di installare iplist/ipblock per proteggere il mulo ma da quel momento non mi è stato più possibile collegarmi ad ssh da internet, da un pc in LAN inceve non c'è problema.

Il problema sussiste anche se "spengo" iplist/ipblock".

Questo è il risultato di iptables -L

Codice: Seleziona tutto

Chain INPUT (policy DROP)
target     prot opt source               destination
BLACKLIST  tcp  --  anywhere             anywhere            tcp dpt:ssh flags:FIN,SYN,RST,ACK/SYN
ACCEPT     all  --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     icmp --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     udp  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:3000
ACCEPT     udp  --  192.168.1.0/24       anywhere            udp dpt:3003
ACCEPT     udp  --  192.168.1.0/24       anywhere            udp dpt:3010
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:4711
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:ssh
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:mysql
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:www
ACCEPT     udp  --  192.168.1.0/24       anywhere            udp dpts:netbios-ns:netbios-dgm
logdrop    udp  --  anywhere             anywhere            udp dpts:netbios-ns:netbios-dgm
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:netbios-ssn
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:microsoft-ds
logdrop    tcp  --  192.168.1.0/24       anywhere            multiport dports netbios-ssn,microsoft-ds
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:swat
ACCEPT     udp  --  192.168.1.0/24       anywhere            udp dpt:domain
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:domain
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:9091
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:54318
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:5900
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:webmin
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:3389
logdrop    all  --  anywhere             anywhere

Chain FORWARD (policy DROP)
target     prot opt source               destination
logdrop    all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere

Chain BLACKLIST (1 references)
target     prot opt source               destination

Chain logdrop (4 references)
target     prot opt source               destination
LOG        all  --  anywhere             anywhere            LOG level warning prefix `LOG_FIREWALL'
DROP       all  --  anywhere             anywhere
e questo è il file di configurazione di /etc/ipblock.conf

Codice: Seleziona tutto

AUTOSTART="No"
IPTABLES_CHAIN_BLOCK="INPUT OUTPUT "
IPTABLES_CHAIN_ALLOW="INPUT OUTPUT"
LESS_MEMORY="No"
BLOCK_LIST="level1.gz ads-trackers-and-bad-pr0n.gz edu.gz spyware.gz bogon.gz "
BLOCK_LIST_INPUT=""
BLOCK_LIST_OUTPUT=""
BLOCK_LIST_FORWARD=""
ALLOW_LIST=""
ALLOW_LIST_INPUT="allow-perm.p2p allow-temp.p2p"
ALLOW_LIST_OUTPUT="allow-perm.p2p allow-temp.p2p"
ALLOW_LIST_FORWARD=""
IGN_TCP_INPUT="22"
IGN_UDP_INPUT=""
IGN_TCP_OUTPUT="http "
IGN_UDP_OUTPUT="domain"
IGN_TCP_FORWARD=""
IGN_UDP_FORWARD=""
IGN_PROTO_INPUT=""
IGN_PROTO_OUTPUT=""
IGN_PROTO_FORWARD=""
IPLIST_LISTDIR="/var/cache/iplist"
LOG_FILE="/var/log/ipblock.log"
LOG_LEVEL="match"
LOG_IPTABLES="No"
VERBOSE="No"
URL_FILE="/etc/ipblock.lists"
UPDATE_STAMP="/var/cache/iplist/.update-stamp"
UPDATE_INTERVAL="1"
http_proxy=""
GUI_START_HIDDEN="No"
GUI_LAST_LOG_LINES="10"
GUI_AUTOSCROLL="Yes"
GUI_THEME="Gtk"
GUI_WHITELIST_PERM="/var/cache/iplist/allow-perm.p2p"
GUI_WHITELIST_TEMP="/var/cache/iplist/allow-temp.p2p"
Dove sbaglio?
Avatar utente
webpatella
Entusiasta Emergente
Entusiasta Emergente
Messaggi: 1185
Iscrizione: lunedì 14 gennaio 2008, 10:14
Contatti:

Re: iptables, ssh ed iplist/ipblock

Messaggio da webpatella »

che chain è blacklist?
Se oggi ho capito qualcosa deve essere obsoleto!!!
Guide & Consigli http://www.easyict.org/guide-consigli.html
Web Directory Free http://www.easyict.org/directory.html
erpomata
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 315
Iscrizione: venerdì 16 maggio 2008, 18:58

Re: iptables, ssh ed iplist/ipblock

Messaggio da erpomata »

è un chain che uso io per controllare gli accessi di ssh.
ma come vedi è vuoto e quindi non fa nulla quindi dovrebbe far passare i pacchetti.
Avatar utente
webpatella
Entusiasta Emergente
Entusiasta Emergente
Messaggi: 1185
Iscrizione: lunedì 14 gennaio 2008, 10:14
Contatti:

Re: iptables, ssh ed iplist/ipblock

Messaggio da webpatella »

Codice: Seleziona tutto

 BLACKLIST  tcp  --  anywhere             anywhere            tcp dpt:ssh flags:FIN,SYN,RST,ACK/SYN 
prova :

Codice: Seleziona tutto

 ALLOW  tcp  --  anywhere             anywhere            tcp dpt:ssh flags:FIN,SYN,RST,ACK/SYN 
cioè --jump ACCEPT a fine direttiva

secondo me tu spari su blacklist e li si pianta perchè poi non lo autorizzi:

input -allow-> blacklist -??->
Se oggi ho capito qualcosa deve essere obsoleto!!!
Guide & Consigli http://www.easyict.org/guide-consigli.html
Web Directory Free http://www.easyict.org/directory.html
erpomata
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 315
Iscrizione: venerdì 16 maggio 2008, 18:58

Re: iptables, ssh ed iplist/ipblock

Messaggio da erpomata »

Nulla ho provato anche a riavviare il firewall togliendo la chain BLACKLIST ma nulla.

Queste sono le nuove regole del firewall:

Codice: Seleziona tutto

Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     icmp --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     udp  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:3000
ACCEPT     udp  --  192.168.1.0/24       anywhere            udp dpt:3003
ACCEPT     udp  --  192.168.1.0/24       anywhere            udp dpt:3010
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:4711
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:ssh
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:mysql
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:www
ACCEPT     udp  --  192.168.1.0/24       anywhere            udp dpts:netbios-ns:netbios-dgm
logdrop    udp  --  anywhere             anywhere            udp dpts:netbios-ns:netbios-dgm
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:netbios-ssn
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:microsoft-ds
logdrop    tcp  --  192.168.1.0/24       anywhere            multiport dports netbios-ssn,microsoft-ds
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:swat
ACCEPT     udp  --  192.168.1.0/24       anywhere            udp dpt:domain
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:domain
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:9091
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:54318
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:5900
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:webmin
ACCEPT     tcp  --  192.168.1.0/24       anywhere            tcp dpt:3389
logdrop    all  --  anywhere             anywhere

Chain FORWARD (policy DROP)
target     prot opt source               destination
logdrop    all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere

Chain logdrop (4 references)
target     prot opt source               destination
LOG        all  --  anywhere             anywhere            LOG level warning prefix `LOG_FIREWALL'
DROP       all  --  anywhere             anywhere
Ovviamente se butto giù il firewall tutto funziona.

Non è che da qualche parte c'è scritto quali indirizzi accettare?
Ultima modifica di erpomata il venerdì 6 marzo 2009, 7:04, modificato 1 volta in totale.
Avatar utente
webpatella
Entusiasta Emergente
Entusiasta Emergente
Messaggi: 1185
Iscrizione: lunedì 14 gennaio 2008, 10:14
Contatti:

Re: iptables, ssh ed iplist/ipblock

Messaggio da webpatella »

tu dai come policy DROP ad input e poi:
ACCEPT    all  --  anywhere            anywhere
??? :-[
Se oggi ho capito qualcosa deve essere obsoleto!!!
Guide & Consigli http://www.easyict.org/guide-consigli.html
Web Directory Free http://www.easyict.org/directory.html
erpomata
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 315
Iscrizione: venerdì 16 maggio 2008, 18:58

Re: iptables, ssh ed iplist/ipblock

Messaggio da erpomata »

Carina questa mica me ne ero accorto.  >:( >:(

Fatto sta che non accetta le richieste comunque. Non capisco
Avatar utente
webpatella
Entusiasta Emergente
Entusiasta Emergente
Messaggi: 1185
Iscrizione: lunedì 14 gennaio 2008, 10:14
Contatti:

Re: iptables, ssh ed iplist/ipblock

Messaggio da webpatella »

1 - rimuovi ipblock...poi ti spiego come fartelo da te
2 - pulisci tutte le tabelle con -X -F
3 - fai partire il tuo script e se puoi postamelo (se vuoi in pm)
Se oggi ho capito qualcosa deve essere obsoleto!!!
Guide & Consigli http://www.easyict.org/guide-consigli.html
Web Directory Free http://www.easyict.org/directory.html
erpomata
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 315
Iscrizione: venerdì 16 maggio 2008, 18:58

Re: iptables, ssh ed iplist/ipblock

Messaggio da erpomata »

Allora, il problema di accept all è dovuta a queste regole:

Codice: Seleziona tutto

        $IPTABLES -A INPUT  -i lo -j ACCEPT
        $IPTABLES -A OUTPUT -o lo -j ACCEPT
Che faccio?
Avatar utente
webpatella
Entusiasta Emergente
Entusiasta Emergente
Messaggi: 1185
Iscrizione: lunedì 14 gennaio 2008, 10:14
Contatti:

Re: iptables, ssh ed iplist/ipblock

Messaggio da webpatella »

allora è giusto che accetti tutto in loop
$IPTABLES -A INPUT  -i lo -s 127.0.0.1 -j ACCEPT
$IPTABLES -A OUTPUT -o lo -s 127.0.0.1 -j ACCEPT
Se oggi ho capito qualcosa deve essere obsoleto!!!
Guide & Consigli http://www.easyict.org/guide-consigli.html
Web Directory Free http://www.easyict.org/directory.html
erpomata
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 315
Iscrizione: venerdì 16 maggio 2008, 18:58

Re: iptables, ssh ed iplist/ipblock

Messaggio da erpomata »

Ok grazie mille sono riuscito a risolvere tutto.
Il firewall di ubuntu non centrava nulla.

Ora come lo configuro iplist?
Scrivi risposta

Ritorna a “Sicurezza”

Chi c’è in linea

Visualizzano questa sezione: 0 utenti iscritti e 2 ospiti