Portál AbcLinuxu, 30. října 2025 01:11
/etc):
iptables-save > /etc/iptables.rules
iptables v adresáři /etc/network/if-pre-up.d/ (předpokládám, že tam takový soubor není) a nastavit mu execute bit.echo -e "#\!/bin/bash\n/sbin/iptables-restore < /etc/iptables.rules" > /etc/network/if-pre-up.d/iptables chmod 755 /etc/network/if-pre-up.d/iptables
/etc/iptables.rules - vlastník root a oprávnění 644.Keby som to chcela urobit cez nano /etc/network/if-pre-up.d/iptables dnu by stacilo napisat /bin/bash /sbin/iptables-restore nano /sbin/iptables-restore /etc/iptables.rules nano /bin/bash /etc/iptables.rules (Ci uplne zle som to pochopila?) ako skontrolujem opravnenia? /etc/iptables.rules
¡Zle!
První musíš nějaká pravidla mít, ty pak pomocí
iptables-save > /etc/iptables.rulesuložíš do souboru
/etc/iptables.rules.
Pak musíš zařídit, aby se ti včas nahrála, vytvoříš soubor:
nano /etc/network/if-pre-up.d/iptablesa vložíš do něj
#!/bin/bash /sbin/iptables-restore < /etc/iptables.rulesNastavíš mu execute bit:
chmod 755 /etc/network/if-pre-up.d/iptables
Tím do ničeho nezasáhneš a nic needituješ, rozhodně ne /sbin/iptables-restore nebo dokonce /bin/bash (to jsem nepochopil).
Oprávnění zkontroluješ třeba:
ls -l /etc/iptables.rulesNěco jako:
-rw-r--r-- root root by tam mělo být.
auto eth0 iface eth0 inet static address 192.168.0.10 netmask 255.255.255.0 gateway 192.168.0.1 pre-up iptables-restore < /etc/iptables.rules # loadnuti firewallu, prej nastartovanim sitoveho rozhrani post-down iptables -F && iptables -F -t nat # smaznuti firewalu pri dektivaci (nutne kvuli "service networking restart", protize jinak by se firewall. pravidla nacitaly 2x)
cat /etc/interfaces/networking cat /etc/iptables.rules
man iptables-restore
-n, --noflush
don't flush the previous contents of the table. If not speci‐
fied, iptables-restore flushes (deletes) all previous contents
of the respective IP Table.
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
pre-up iptables-restore < /etc/iptables.rules
down iptables -F && iptables -F -t nat
auto eth1
iface eth1 inet static
address 172.16.1.254
netmask 255.255.255.0
up mii-tool -F 10baseT-HD eth1
auto eth2
iface eth2 inet static
address 172.16.2.254
netmask 255.255.255.0
auto wlan0
iface wlan0 inet static
address 172.16.3.254
netmask 255.255.255.0
up iwconfig wlan0 rate 10M
Momentalne mam teda na alixu debian7, predtim jsem mel debian6 (tehdy kdyz jsem to zkousel tak se to duplikovalo), je mozne ze tam byl nejaky starsi iptables. Zkusil bych to restartoval, ale nerad bych se ustrihnul. Takze to zahrajem do ztracena... :)
apt-get install iptables-persistent a pak iptables-save > /etc/iptables/rules.
iptables-save > /etc/iptables/rules.v4 a případně ip6tables-save > /etc/iptables/rules.v6.
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.