Fórum Ubuntu CZ/SK
Ubuntu pro osobní počítače => Internet a sítě => Téma založeno: Šuohob 30 Července 2009, 12:11:10
-
Dobrý den, snažil jsem se nějak nastavit firewall. Nastavoval jsem to s ufw i gufw.
Problém je, že když mám nastavená nějaká pravidla a dám ufw enable, tak se pravidla zapíší do iptables, ale po restartu tam už nejsou.
Zapnutí před restartem:
root@notes:~# ufw enable
Firewall is active and enabled on system startup
root@notes:~# ufw status
Status: active
To Action From
-- ------ ----
631 DENY Anywhere
3306 DENY Anywhere
80 DENY Anywhere
Pravidla (zdá se) se zapíšou do iptables:
root@notes:~# iptables -L
Chain INPUT (policy DROP)
target prot opt source destination
ufw-before-logging-input all -- anywhere anywhere
ufw-before-input all -- anywhere anywhere
ufw-after-input all -- anywhere anywhere
ufw-after-logging-input all -- anywhere anywhere
ufw-reject-input all -- anywhere anywhere
Chain FORWARD (policy DROP)
target prot opt source destination
ufw-before-logging-forward all -- anywhere anywhere
ufw-before-forward all -- anywhere anywhere
ufw-after-forward all -- anywhere anywhere
ufw-after-logging-forward all -- anywhere anywhere
ufw-reject-forward all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ufw-before-logging-output all -- anywhere anywhere
ufw-before-output all -- anywhere anywhere
ufw-after-output all -- anywhere anywhere
ufw-after-logging-output all -- anywhere anywhere
ufw-reject-output all -- anywhere anywhere
Chain ufw-after-forward (1 references)
target prot opt source destination
Chain ufw-after-input (1 references)
target prot opt source destination
RETURN udp -- anywhere anywhere udp dpt:netbios-ns
RETURN udp -- anywhere anywhere udp dpt:netbios-dgm
RETURN tcp -- anywhere anywhere tcp dpt:netbios-ssn
RETURN tcp -- anywhere anywhere tcp dpt:microsoft-ds
RETURN udp -- anywhere anywhere udp dpt:bootps
RETURN udp -- anywhere anywhere udp dpt:bootpc
RETURN all -- anywhere anywhere ADDRTYPE match dst-type BROADCAST
Chain ufw-after-logging-forward (1 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix `[UFW BLOCK] '
Chain ufw-after-logging-input (1 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix `[UFW BLOCK] '
Chain ufw-after-logging-output (1 references)
target prot opt source destination
Chain ufw-after-output (1 references)
target prot opt source destination
Chain ufw-before-forward (1 references)
target prot opt source destination
ufw-user-forward all -- anywhere anywhere
Chain ufw-before-input (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ufw-logging-deny all -- anywhere anywhere state INVALID
DROP all -- anywhere anywhere state INVALID
ACCEPT icmp -- anywhere anywhere icmp destination-unreachable
ACCEPT icmp -- anywhere anywhere icmp source-quench
ACCEPT icmp -- anywhere anywhere icmp time-exceeded
ACCEPT icmp -- anywhere anywhere icmp parameter-problem
ACCEPT icmp -- anywhere anywhere icmp echo-request
ACCEPT udp -- anywhere anywhere udp spt:bootps dpt:bootpc
ufw-not-local all -- anywhere anywhere
ACCEPT all -- BASE-ADDRESS.MCAST.NET/4 anywhere
ACCEPT all -- anywhere BASE-ADDRESS.MCAST.NET/4
ufw-user-input all -- anywhere anywhere
Chain ufw-before-logging-forward (1 references)
target prot opt source destination
Chain ufw-before-logging-input (1 references)
target prot opt source destination
Chain ufw-before-logging-output (1 references)
target prot opt source destination
Chain ufw-before-output (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere state NEW,RELATED,ESTABLISHED
ACCEPT udp -- anywhere anywhere state NEW,RELATED,ESTABLISHED
ufw-user-output all -- anywhere anywhere
Chain ufw-logging-allow (0 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix `[UFW ALLOW] '
Chain ufw-logging-deny (2 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix `[UFW BLOCK] '
Chain ufw-not-local (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere ADDRTYPE match dst-type LOCAL
RETURN all -- anywhere anywhere ADDRTYPE match dst-type MULTICAST
RETURN all -- anywhere anywhere ADDRTYPE match dst-type BROADCAST
ufw-logging-deny all -- anywhere anywhere limit: avg 3/min burst 10
DROP all -- anywhere anywhere
Chain ufw-reject-forward (1 references)
target prot opt source destination
Chain ufw-reject-input (1 references)
target prot opt source destination
Chain ufw-reject-output (1 references)
target prot opt source destination
Chain ufw-user-forward (1 references)
target prot opt source destination
Chain ufw-user-input (1 references)
target prot opt source destination
DROP tcp -- anywhere anywhere tcp dpt:ipp
DROP udp -- anywhere anywhere udp dpt:ipp
DROP tcp -- anywhere anywhere tcp dpt:mysql
DROP udp -- anywhere anywhere udp dpt:mysql
DROP tcp -- anywhere anywhere tcp dpt:www
DROP udp -- anywhere anywhere udp dpt:www
Chain ufw-user-limit (0 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 5 LOG level warning prefix `[UFW LIMIT BLOCK] '
REJECT all -- anywhere anywhere reject-with icmp-port-unreachable
Chain ufw-user-limit-accept (0 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
Chain ufw-user-logging-forward (0 references)
target prot opt source destination
Chain ufw-user-logging-input (0 references)
target prot opt source destination
Chain ufw-user-logging-output (0 references)
target prot opt source destination
Chain ufw-user-output (1 references)
target prot opt source destination
Ufw se po restartu počítače souští se startem systému, ale v iptables už nejsou žádná pravidla. Zkoušel jsem i do aplikací spouštěných při přihlášení dát sudo ufw enable, ale marně...
Po restartu:
root@notes:~# ufw status
Status: inactive
root@notes:~# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Co dělám špatně?
-
Co dělám špatně?
Nevidím v Tvém postupu žádnou chybu. Zkus to znovu:
- aktivuj ufw a dej tam nějaká pravidla, pak zkopíruj co vypíše
sudo ufw status
ls -l /var/lib/ufw/user.rules
cat /var/lib/ufw/user.rules
sudo /etc/init.d/ufw stop
sudo ufw status
cat /var/lib/ufw/user.rules
sudo /etc/init.d/ufw start
sudo ufw status
cat /var/lib/ufw/user.rules(tedy jak se chová ufw po reloadu a jestli zapisuje do konf. souboru).
-
Zjistil jsem, že firewall se mi vypne ne po restartu počítače, jak jsem si myslel, ale ihned po připojení k síti. Takže to jak jsem uvedl po restartu počítače je vlastně až po připojení k síti. Zkoušel jsem se připojovat pomocí gnome-ppp k mobilnímu telefonu, ale myslím, že mi to deaktivuje firewall i když se připojuji na wifi, nebo na eth0 (normální síťovka).
Fakt nevím co s tím...
-
Tak jsem si nainstaloval firestarter a nastavil jsem si, že jakmile z DHCP dostanu adresu, tak se firewall zapne. To funguje, takže se situace nějak vyřešila sama. Nevíte někdo, proč po zapnutí firewallu pomocí ufw/Gufw a po následném připojení k síti firewall vypínal?
-
Firestarter má drobné úskalí. Jde v něm nadefinovat pouze jedno preferované připojení, takže když si tam nastavím jako preferované připojení ppp0 a připojím se na eth0, tak se mi firewall nezapne. Můžete mi prosím poradit nějaký konfigurák firewallu, který bude fungovat tak jak má a firewall se tam bude moci nastavit pro všechna zařízení (eth0, wlan0...) připojitelná k síti?
-
Nainstaloval jsem firehol Povolil jsem spuštění v /etc/firehol/firehol.conf. Nic jiného jsem nenastavoval. Pak jsem ho pustil: sudo /etc/init.d/firehol start a on vygeneroval nastavení iptables. Zahazuje toto defaultní nastavení všechny příchozí pakety? Přikládám výpis sudo iptables -L:
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere
in_world all -- anywhere anywhere
ACCEPT all -- anywhere anywhere state RELATED
LOG all -- anywhere anywhere limit: avg 1/sec burst 5 LOG level warning prefix `'IN-unknown:''
DROP all -- anywhere anywhere
Chain FORWARD (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED
LOG all -- anywhere anywhere limit: avg 1/sec burst 5 LOG level warning prefix `'PASS-unknown:''
DROP all -- anywhere anywhere
Chain OUTPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere
out_world all -- anywhere anywhere
ACCEPT all -- anywhere anywhere state RELATED
LOG all -- anywhere anywhere limit: avg 1/sec burst 5 LOG level warning prefix `'OUT-unknown:''
DROP all -- anywhere anywhere
Chain in_world (1 references)
target prot opt source destination
in_world_all_c1 all -- anywhere anywhere
in_world_irc_c2 all -- anywhere anywhere
in_world_ftp_c3 all -- anywhere anywhere
ACCEPT all -- anywhere anywhere state RELATED
LOG all -- anywhere anywhere limit: avg 1/sec burst 5 LOG level warning prefix `''IN-world':''
DROP all -- anywhere anywhere
Chain in_world_all_c1 (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere state ESTABLISHED
Chain in_world_ftp_c3 (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp spt:ftp dpts:32768:61000 state ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp spt:ftp-data dpts:32768:61000 state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp spts:1024:65535 dpts:32768:61000 state ESTABLISHED
Chain in_world_irc_c2 (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp spt:ircd dpts:32768:61000 state ESTABLISHED
Chain out_world (1 references)
target prot opt source destination
out_world_all_c1 all -- anywhere anywhere
out_world_irc_c2 all -- anywhere anywhere
out_world_ftp_c3 all -- anywhere anywhere
ACCEPT all -- anywhere anywhere state RELATED
LOG all -- anywhere anywhere limit: avg 1/sec burst 5 LOG level warning prefix `''OUT-world':''
DROP all -- anywhere anywhere
Chain out_world_all_c1 (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere state NEW,ESTABLISHED
Chain out_world_ftp_c3 (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp spts:32768:61000 dpt:ftp state NEW,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp spts:32768:61000 dpt:ftp-data state ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp spts:32768:61000 dpts:1024:65535 state RELATED,ESTABLISHED
Chain out_world_irc_c2 (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp spts:32768:61000 dpt:ircd state NEW,ESTABLISHED
-
Jak už to tak bývá, co si člověk neudělá sám, to nemá, tak já si už po čtvrté sám odpovím: ano, zahazuje, alespoň to píše, viz
cat /etc/firehol/firehol.conf
#
# $Id: client-all.conf,v 1.2 2002/12/31 15:44:34 ktsaou Exp $
#
# This configuration file will allow all requests originating from the
# local machine to be send through all network interfaces.
#
# No requests are allowed to come from the network. The host will be
# completely stealthed! It will not respond to anything, and it will
# not be pingable, although it will be able to originate anything
# (even pings to other hosts).
#
version 5
# Accept all client traffic on any interface
interface any world
client all accept
Další materiály: http://www.root.cz/clanky/firehol-nejsnazsi-firewall/ (http://www.root.cz/clanky/firehol-nejsnazsi-firewall/)
Tento nastavovač iptables mi nemaže pravidla při připojení k síti a nedělá pokud vím vůbec žádné kixy. Takže pokud někdo bude mít podobný problém, firehol doporučuji.
pryč s tou hrůzou
sudo apt-get --purge remove firestarter
sudo apt-get --purge remove gufw
Takže VYŘEŠENO