1. Maak eerst een back-up van iptables
# cp /etc/sysconfig/iptables /var/tmp Je moet poort 80 openen en het IP- en LAN-adres opgeven De betekenis van de volgende drie regels: Sluit eerst alle poorten 80 Open 80 poorten op het IP-segment 192.168.1.0/24 Open 80 poorten van het IP-segment van het IP-segment 211.123.16.123/24 # iptables -I INPUT -p tcp --dport 80 -j DROP # iptables -I INPUT -s 192.168.1.0/24 -p tcp --dport 80 -j ACCEPTEREN # iptables -I INPUT -s 211.123.16.123/24 -p tcp --dport 80 -j ACCEPTEREN Bovenstaande is een tijdelijke situatie. 2. Sla vervolgens iptables op # service iptables save 3. Herstel de firewall opnieuw #service iptables herstarten ===============Het volgende is een herdruk ================================================ Hieronder volgen de poorten, die allemaal geblokkeerd zijn voordat sommige IP's worden geopend iptables -I INPUT -p tcp --dport 9889 -j DROP iptables -I INPUT -s 192.168.1.0/24 -p tcp --dport 9889 -j ACCEPTEREN Als NAT-doorsturing wordt gebruikt, vergeet dan niet mee te werken aan het volgende om van kracht te worden iptables -I FORWARD -p tcp --dport 80 -j DROP iptables -I FORWARD -s 192.168.1.0/24 -p tcp --dport 80 -j ACCEPTEREN
De veelgebruikte IPTABLES-regels zijn als volgt: Je kunt alleen e-mails versturen en ontvangen, de rest is gesloten iptables -I Filter -m mac --mac-source 00:0F:EA:25:51:37 -j DROP iptables -I Filter -m mac --mac-source 00:0F:EA:25:51:37 -p udp --dport 53 -j ACCEPTEREN iptables -I Filter -m mac --mac-source 00:0F:EA:25:51:37 -p tcp --dport 25 -j ACCEPTEREN iptables -I Filter -m mac --mac-source 00:0F:EA:25:51:37 -p tcp --dport 110 -j ACCEPTEREN
IPSEC NAT-beleid iptables -I PFWanPriv -d 192.168.100.2 -j ACCEPTEREN iptables -t nat -A PREROUTING -p tcp --dport 80 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.100.2:80 iptables -t nat -A PREROUTING -p tcp --dport 1723 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.100.2:1723 iptables -t nat -A PREROUTING -p udp --dport 1723 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.100.2:1723 iptables -t nat -A PREROUTING -p udp --dport 500 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.100.2:500 iptables -t nat -A PREROUTING -p udp --dport 4500 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.100.2:4500
NAT voor FTP-server iptables -I PFWanPriv -p tcp --dport 21 -d 192.168.100.200 -j ACCEPT iptables -t nat -A PREROUTING -p tcp --dport 21 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.100.200:21
Alleen de opgegeven URL is toegestaan iptables -A Filter -p udp --dport 53 -j ACCEPT iptables -A Filter -p tcp --dport 53 -j ACCEPT iptables -A Filter -d www.3322.org -j ACCEPTEREN iptables -A Filter -d img.cn99.com -j ACCEPTEREN iptables -A Filter -j DROP
Sommige poorten van een IP zijn open, andere gesloten iptables -A Filter -p tcp --dport 80 -s 192.168.100.200 -d www.pconline.com.cn -j ACCEPTEREN iptables -A Filter -p tcp --dport 25 -s 192.168.100.200 -j ACCEPTEREN iptables -A Filter -p tcp --dport 109 -s 192.168.100.200 -j ACCEPT iptables -A Filter -p tcp --dport 110 -s 192.168.100.200 -j ACCEPT iptables -A Filter -p tcp --dport 53 -j ACCEPT iptables -A Filter -p udp --dport 53 -j ACCEPT iptables -A Filter -j DROP
Meerdere poorten iptables -A Filter -p tcp -m multiport --destination-port 22,53,80,110 -s 192.168.20.3 -j REJECT
Continue poort iptables -A Filter -p tcp -m multiport --source-port 22,53,80,110 -s 192.168.20.3 -j REJECT iptables -A Filter -p tcp --source-port 2:80 -s 192.168.20.3 -j REJECT
Geef de tijd aan om op internet te surfen iptables -A Filter -s 10.10.10.253 -m tijd --tijdstart 6:00 --tijdstop 11:00 --dagen ma, dinsdag, woensdag, donderdag, vr, za, zon -j drop iptables -A Filter -m tijd --timestart 12:00 --timestop 13:00 --dagen ma, dinsdag, woensdag, donderdag, vr, za, zon -j ACCEPTEREN iptables -A Filter -m tijd --timestart 17:30 --timestop 8:30 --dagen ma, dinsdag, woensdag, do, vr, zaterdag, zon -j ACCEPTEREN Meervoudige havendiensten zijn verboden iptables -A Filter -m multiport -p tcp --dport 21,23,80 -j ACCEPTEREN
NAT de WAN-poort naar de pc iptables -t nat -A PREROUTING -i $INTERNET_IF -d $INTERNET_ADDR -j DNAT --to-destination 192.168.0.1
NAT-poort 8000 naar 192. 168。 100。 200 ports van 80 iptables -t nat -A PREROUTING -p tcp --dport 8000 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.100.200:80
De poort die de MAIL-server wil doorsturen iptables -t nat -A PREROUTING -p tcp --dport 110 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.100.200:110 iptables -t nat -A PREROUTING -p tcp --dport 25 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.100.200:25
Alleen PING 202 is toegestaan. 96。 134。 133. Andere diensten zijn verboden iptables -A Filter -p icmp -s 192.168.100.200 -d 202.96.134.133 -j ACCEPT iptables -A Filter -j DROP Schakel BT-configuratie uit iptables –A Filter –p tcp –dport 6000:20000 –j DROP Schakel de QQ-firewallconfiguratie uit iptables -A Filter -p udp --dport ! 53 -j DROP iptables -A Filter -d 218.17.209.0/24 -j DROP iptables -A Filter -d 218.18.95.0/24 -j DROP iptables -A Filter -d 219.133.40.177 -j DROP Op basis van MAC kan het alleen e-mails verzenden en ontvangen, en alle andere e-mails weigeren iptables -I Filter -m mac --mac-source 00:0A:EB:97:79:A1 -j DROP iptables -I Filter -m mac --mac-source 00:0A:EB:97:79:A1 -p tcp --dport 25 -j ACCEPTEREN iptables -I Filter -m mac --mac-source 00:0A:EB:97:79:A1 -p tcp --dport 110 -j ACCEPTEREN Schakel de MSN-configuratie uit iptables -A Filter -p udp --dport 9 -j DROP iptables -A Filter -p tcp --dport 1863 -j DROP iptables -A Filter -p tcp --dport 80 -d 207.68.178.238 -j DROP iptables -A Filter -p tcp --dport 80 -d 207.46.110.0/24 -j DROP Alleen PING 202 is toegestaan. 96。 134。 133 PING is niet toegestaan op andere openbare netwerk-IP's iptables -A Filter -p icmp -s 192.168.100.200 -d 202.96.134.133 -j ACCEPT iptables -A Filter -p icmp -j DROP Verbied een MAC-adres toegang tot het internet: iptables -I Filter -m mac --mac-source 00:20:18:8F:72:F8 -j DROP Ping naar een IP-adres: iptables –A Filter –p icmp –s 192.168.0.1 –j DROP Verbied een IP-adres om te bedienen: iptables –A Filter -p tcp -s 192.168.0.1 --dport 80 -j DROP iptables –A Filter -p udp -s 192.168.0.1 --dport 53 -j DROP Alleen bepaalde diensten zijn toegestaan, andere worden afgewezen (2 regels) iptables -A Filter -p tcp -s 192.168.0.1 --dport 1000 -j ACCEPTEREN iptables -A Filter -j DROP Een poortdienst voor een IP-adres is verboden iptables -A Filter -p tcp -s 10.10.10.253 --dport 80 -j ACCEPT iptables -A Filter -p tcp -s 10.10.10.253 --dport 80 -j DROP Verbied een poortdienst voor een MAC-adres iptables -I Filter -p tcp -m mac --mac-source 00:20:18:8F:72:F8 --dport 80 -j DROP Verbied een MAC-adres toegang tot het internet: iptables -I Filter -m mac --mac-source 00:11:22:33:44:55 -j DROP Ping naar een IP-adres: iptables –A Filter –p icmp –s 192.168.0.1 –j DROP
|