-hanz-
07.10.05, 14:07
Hi Leute,
System ist Slackware 10.1 mit selbst kompiliertem Kernel 2.6.11.7, ohne Module (alles im Kernel)
Interfaces sind
eth0 --> wird im moment noch nicht benötigt (aber vermutlich bald)
eth1 --> is fürs lokale Netz, der Weg nach drausen also :)
eth2 --> hängt dsl dran, also nicht soo wichtig
ppp0 --> DSL halt
So nun zum Ziel, das Script soll für mich routen und Verbindungen zum Router/Server von ausen abblocken (soll ja auch sicher sein :)) Bisher hab ich narc benutzt (setzt auf iptables auf, und man kann seine Einstellungen in Config-files machen), aber das ist nicht mein Ding, weil man da ja nicht so richtig weiß was das so wirklich macht.
Problem ist an meinem Script nun, das es keinen Zugriff mehr aus dem Lan zulässt, vorhandene (z. B. die ssh-session mit der ich es starte) werden aber nicht getrennt. Routing tut auch noch nicht.
Hier dann mal das Script:
#-------------------------------------------------------------------------------------------------
# | Firewallscript |
# | |
# -------------------------------------------------------------------------------------------------
# ----------------------------------------------------------------------- Forwarding aktivieren ---
echo 1 >> /proc/sys/net/ipv4/ip_forward
echo 1 >> /proc/sys/net/ipv4/ip_dynaddr
# ------------------------------------------------------------------------- alte Regeln löschen ---
iptables -t filter -F
iptables -t nat -F
# --------------------------------------------------------------------- Masquerading aktivieren ---
iptables -t nat -A POSTROUTING -o ppp+ -s 192.168.0.0/24 -j MASQUERADE
# -------------------------------- MSS der Pakete ins I-Net an die MTU von DSL (=1492) anpassen ---
iptables -A FORWARD -o ppp+ -p TCP --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
# ------------------------------------------------------------- Verbindung aus dem Lan erlauben ---
iptables -A INPUT -m state --state NEW -i ! ppp+ -j ACCEPT
# --------------------------------- Vorhandene oder Wiederhergestellte Verbindungen akzeptieren ---
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# --------------------- Pakete aus I-Net mit privaten (gefaelschten) Absenderadressen verwerfen ---
# prerouting
iptables -t nat -A PREROUTING -i ppp+ -s 192.168.0.0/16 -j DROP
iptables -t nat -A PREROUTING -i ppp+ -s 10.0.0.0/8 -j DROP
iptables -t nat -A PREROUTING -i ppp+ -s 172.16.0.0/12 -j DROP
iptables -t nat -A PREROUTING -i ppp+ -s 127.0.0.0/8 -j DROP
# forwarding
iptables -A FORWARD -i ppp+ -s 192.168.0.0/16 -j DROP
iptables -A FORWARD -i ppp+ -s 10.0.0.0/8 -j DROP
iptables -A FORWARD -i ppp+ -s 172.16.0.0/12 -j DROP
iptables -A FORWARD -i ppp+ -s 127.0.0.0/8 -j DROP
# local input
iptables -A INPUT -i ppp+ -s 192.168.0.0/16 -j DROP
iptables -A INPUT -i ppp+ -s 10.0.0.0/8 -j DROP
iptables -A INPUT -i ppp+ -s 172.16.0.0/12 -j DROP
iptables -A INPUT -i ppp+ -s 127.0.0.0/8 -j DROP
# ----------------------------------------------------------------------- Default Policy setzen ---
iptables -t filter -P INPUT DROP
iptables -t filter -P FORWARD DROP
iptables -t filter -P OUTPUT DROP
iptables -t nat -P PREROUTING DROP
iptables -t nat -P POSTROUTING DROP
Output von iptables -L
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere state NEW
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
DROP all -- localnet/16 anywhere
DROP all -- 10.0.0.0/8 anywhere
DROP all -- 172.16.0.0/12 anywhere
DROP all -- loopback/8 anywhere
Chain FORWARD (policy DROP)
target prot opt source destination
TCPMSS tcp -- anywhere anywhere tcp flags:SYN,RST/SYN TCPMSS clamp to PMTU
DROP all -- localnet/16 anywhere
DROP all -- 10.0.0.0/8 anywhere
DROP all -- 172.16.0.0/12 anywhere
DROP all -- loopback/8 anywhere
Chain OUTPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
Vielen Dank schonmal im Vorraus
MfG
-hanz-
System ist Slackware 10.1 mit selbst kompiliertem Kernel 2.6.11.7, ohne Module (alles im Kernel)
Interfaces sind
eth0 --> wird im moment noch nicht benötigt (aber vermutlich bald)
eth1 --> is fürs lokale Netz, der Weg nach drausen also :)
eth2 --> hängt dsl dran, also nicht soo wichtig
ppp0 --> DSL halt
So nun zum Ziel, das Script soll für mich routen und Verbindungen zum Router/Server von ausen abblocken (soll ja auch sicher sein :)) Bisher hab ich narc benutzt (setzt auf iptables auf, und man kann seine Einstellungen in Config-files machen), aber das ist nicht mein Ding, weil man da ja nicht so richtig weiß was das so wirklich macht.
Problem ist an meinem Script nun, das es keinen Zugriff mehr aus dem Lan zulässt, vorhandene (z. B. die ssh-session mit der ich es starte) werden aber nicht getrennt. Routing tut auch noch nicht.
Hier dann mal das Script:
#-------------------------------------------------------------------------------------------------
# | Firewallscript |
# | |
# -------------------------------------------------------------------------------------------------
# ----------------------------------------------------------------------- Forwarding aktivieren ---
echo 1 >> /proc/sys/net/ipv4/ip_forward
echo 1 >> /proc/sys/net/ipv4/ip_dynaddr
# ------------------------------------------------------------------------- alte Regeln löschen ---
iptables -t filter -F
iptables -t nat -F
# --------------------------------------------------------------------- Masquerading aktivieren ---
iptables -t nat -A POSTROUTING -o ppp+ -s 192.168.0.0/24 -j MASQUERADE
# -------------------------------- MSS der Pakete ins I-Net an die MTU von DSL (=1492) anpassen ---
iptables -A FORWARD -o ppp+ -p TCP --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
# ------------------------------------------------------------- Verbindung aus dem Lan erlauben ---
iptables -A INPUT -m state --state NEW -i ! ppp+ -j ACCEPT
# --------------------------------- Vorhandene oder Wiederhergestellte Verbindungen akzeptieren ---
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# --------------------- Pakete aus I-Net mit privaten (gefaelschten) Absenderadressen verwerfen ---
# prerouting
iptables -t nat -A PREROUTING -i ppp+ -s 192.168.0.0/16 -j DROP
iptables -t nat -A PREROUTING -i ppp+ -s 10.0.0.0/8 -j DROP
iptables -t nat -A PREROUTING -i ppp+ -s 172.16.0.0/12 -j DROP
iptables -t nat -A PREROUTING -i ppp+ -s 127.0.0.0/8 -j DROP
# forwarding
iptables -A FORWARD -i ppp+ -s 192.168.0.0/16 -j DROP
iptables -A FORWARD -i ppp+ -s 10.0.0.0/8 -j DROP
iptables -A FORWARD -i ppp+ -s 172.16.0.0/12 -j DROP
iptables -A FORWARD -i ppp+ -s 127.0.0.0/8 -j DROP
# local input
iptables -A INPUT -i ppp+ -s 192.168.0.0/16 -j DROP
iptables -A INPUT -i ppp+ -s 10.0.0.0/8 -j DROP
iptables -A INPUT -i ppp+ -s 172.16.0.0/12 -j DROP
iptables -A INPUT -i ppp+ -s 127.0.0.0/8 -j DROP
# ----------------------------------------------------------------------- Default Policy setzen ---
iptables -t filter -P INPUT DROP
iptables -t filter -P FORWARD DROP
iptables -t filter -P OUTPUT DROP
iptables -t nat -P PREROUTING DROP
iptables -t nat -P POSTROUTING DROP
Output von iptables -L
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere state NEW
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
DROP all -- localnet/16 anywhere
DROP all -- 10.0.0.0/8 anywhere
DROP all -- 172.16.0.0/12 anywhere
DROP all -- loopback/8 anywhere
Chain FORWARD (policy DROP)
target prot opt source destination
TCPMSS tcp -- anywhere anywhere tcp flags:SYN,RST/SYN TCPMSS clamp to PMTU
DROP all -- localnet/16 anywhere
DROP all -- 10.0.0.0/8 anywhere
DROP all -- 172.16.0.0/12 anywhere
DROP all -- loopback/8 anywhere
Chain OUTPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
Vielen Dank schonmal im Vorraus
MfG
-hanz-