Redhat als Router XP als Client kein Internet, ICQ & Skype OK????

S

stinkefischs

Grünschnabel
Hallo zusammen,
Ok dies ist mein erstes Threat und schon geht alles drunter und drüber.
Also, folgendes Problem.
Ich will RedHat als Router, Firewall, Apache und Email Server einsetzen.
Soweit so gut. Alles soweit installiert und dachte mir jetzt kann es locker losgehen aber nix geht.
Zur Hardware:
Rechner mit Redhat (der Router) hat 2 Netzwerkkarten eth0 (extern DHCP eingestellt NTL als Internet Provider) und eth1 internes Netzwerk 192.168.0.5 255.255.255.0.
Als Client habe ich mehrere Rechner mit XP & Suse. Verbindung via ssh funktioniert auf den Redhat Rechner (192.168.0.5).
Ich habe /etc/hosts.deny folgendermassen editiert:
ALL: ALL
und /etc/hosts.allow
ALL: 127.0.0.1
ALL: 192.168.0.

Hier noch meine Route Ausgabe:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth1
86.4.0.0 * 255.255.252.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth1
default ubr01runc-bundl 0.0.0.0 UG 0 0 0 eth0

desweiterern:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "1" > /proc/sys/net/ipv4/ip_forward

dachte das es alles aus dem internen netz nach draussen routet, tut es auch, aber nur ICQ & Skype, der Browser sagt mir nur die Seite kann nicht angezeigt werden??????????????????????
Ich habe bei allen PC's im internen Netz als Gateway 192.168.0.5 angegeben.
Ich dreh hier noch ab. Hoffe mir kann jemand weiterhelfen. Arrrrrrrrrrrrrrrr ?(
Super vielen Dank für alle Informationen zu diesem Thema.
 
hallo

hast du vielleicht vergessen bei den clients entsprechende einträge für die DNS abfrage einzustellen? soweit ich weiss kennen icq (und wohl auch) skype ihre ip-adressen, aber wenn du im browser eine adresse eingibst, müsste er diese erst auflösen...

anderes problem, das mir mal wiederfahren ist war, dass beim betrieb eines apaches webservers, ich immer auf diesen kam beim abfragen einer jeden url. (ich hab das dann allerdings nimma weiterverfolgt, was ich damals falsch gemacht hatte), also wäre es möglich, dass dein documentroot im apache leer ist, dieser allerdings läuft und alle port 80 abfragen abfängt??

übrigens willkommen am unixboard!

grüße joe

EDIT: ja das könnte sogar glaub ich tatsächlich passieren, wenn apache auf keine bestimmte ip für port-listening eingstellt ist, ich hatte damals glaub ich auch ne redhat distri in verwendung
 
Zuletzt bearbeitet:
Guten Morgen :D

Prüfe doch mal, ob du bei den Win-Clients bei ´DNS´ und bei den Linux-Clients bei
´nameserver´ die IP-Adresse von deinem Router eingegeben hast.

Beim Router würde ich noch als Nameserver deinen Internetprovider eingeben.
z.B. von 1&1:
62.155.255.16
194.25.2.129

Ich habe /etc/hosts.deny folgendermassen editiert:
ALL: ALL
und /etc/hosts.allow
ALL: 127.0.0.1
ALL: 192.168.0.

Ich mag mich ja irren, aber muss nicht der Broadcast (192.168.0.255)
angegeben werden, damit das gesamte Netzwerk initialisiert wird? ?(

Gegebenenfalls solltest du die Einstellungen von der Firewall des Routers prüfen.

Ich würde aber lieber ´ipcop´ als Router verwenden und einen separaten Server aufbauen.
Oder du verwendest (wie ich) gleich nen Hardware Router mit integrierter Firewall.
Dann steht der server auch dann noch, wenn der Router mal platt ist.

Gruß Lumpi
 
Hallo nochmal ihr beiden und danke fuer die Antworten.
So, habe jetzt folgendes gemacht weil ich einfach nicht drauf gekommen bin.
Ich habe jetzt einen DHCP Server installiert der auch IP's an meine Windows Clienten vergiebt. Soweit so gut, aber leider immer noch kein Internet mit den Kisten.

resolv.conf
nameserver 194.168.8.100
nameserver 194.168.4.100
search bagu.cable.ntl.com

dhcpd.conf
# /etc/dhcpd.conf
# DHCPD Configuration
ddns-update-style interim;
default-lease-time 86400; # one day
max-lease-time 86400; # one day

subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.2 192.168.0.250;

option subnet-mask 255.255.255.0;
option broadcast-address 192.168.0.255;
option routers 192.168.0.1;
}

Alle koennen alle pingen nur die Redhat Kiste will nicht routen???????

route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
255.255.255.255 0.0.0.0 255.255.255.255 UH 0 0 0 eth1
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
86.4.0.0 0.0.0.0 255.255.252.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
0.0.0.0 86.4.0.1 0.0.0.0 UG 0 0 0 eth0


[root@cpc3-runc1-0-0-cust429 etc]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:B0:D0:8B:FC:8C
inet addr:86.4.X.XXX Bcast:255.255.255.255 Mask:255.255.252.0
inet6 addr: fe80::2b0:d0ff:fe8b:fc8c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2143 errors:0 dropped:0 overruns:0 frame:0
TX packets:1735 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1719282 (1.6 MiB) TX bytes:372910 (364.1 KiB)
Interrupt:5 Base address:0xe880

eth1 Link encap:Ethernet HWaddr 00:08:54:36:EB:43
inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::208:54ff:fe36:eb43/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2774 errors:0 dropped:0 overruns:0 frame:0
TX packets:442 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:184860 (180.5 KiB) TX bytes:35196 (34.3 KiB)
Interrupt:5 Base address:0xec00

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:2286 errors:0 dropped:0 overruns:0 frame:0
TX packets:2286 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2996540 (2.8 MiB) TX bytes:2996540 (2.8 MiB)

Windows Client:
Connection Speciffic DNS suffix : mydomain.com
Ipaddress 192.168.0.250
Subnet mask 255.255.255.0
Default Gateway 192.168.0.1

Desweiteren finden meine Clienten keinen DNS Server um Namen zu resolven?
Kann auch von den Clienten den Prim. & Sec. DNS nicht pingen.
Ich hoffe es hat noch jemand Rat, sonst spring ich hier gleich aus'hem Fenster.
Danke

Musste die Router IP von 192.168.0.5 auf 192.168.0.1 aendern.
 
Zuletzt bearbeitet:
Hallo,

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "1" > /proc/sys/net/ipv4/ip_forward

Ist das alles, was Du als Routing und Masquerading veranlasst hast?
Poste mal bitte die Ausgabe von iptables -nL.

Gruß
 
Wenn mich nicht alles täuscht, muss für Windows-Clients noch der Routingeintrag für die Adresse 255.255.255.255 im DHCP-Server eingetragen werden.

route add-host 255.255.255.255 dev eth* (die Netzwerkkarte, die zuständig ist)

Weiter muss man (glaube ich) noch das ip-forwarding aktivieren. Dies kannst Du mit

echo 1 >/proc/sys/nrt/ipv4/ip_forward

erreichen.

Edit:
Damit die Windows-Clients den DNS-Server erkennen und verwenden können, muss in der /etc/dhcpd.conf -Datei auch ein Eintrag für netbios stehen:

option netbios-name-servers <IP des Nameservers>;
option netbios-node-type 8;
option netbios-dd-server <IP des Nameservers>;

Gruß

rp1
 
Zuletzt bearbeitet:
@rp: Ich fürchte, Dich täuscht so einiges ;-)
Noch nicht ganz wach gewesen heute morgen? ;-)

Also:
1. Das Routing für die Broadcast-Adresse muss ganz bestimmt nicht von Hand (oder per DHCP-Server) vergeben werden. Auch nicht bei Windows.
2. echo "1" > /proc/sys/net/ipv4/ip_forward hat er schon gemacht.
3. Damit ein Windows-Client per DNS Rechnernamen auflösen kann, ist es NICHT nötig, einen WINS-Server (netbios-name-server) zu konfigurieren und diesen anzusprechen.

Ich tippe darauf, dass die Maschine nicht sauber routet.

Gruß
 
Skript fuer's Routing:
Code:
#!/bin/bash

echo "Starting firewall"

LOGLIMIT=20
IPTABLES=/sbin/iptables

case "$1" in
start)
	# alle alten Regeln entfernen
	echo "Loesche alte Regeln"
	$IPTABLES -F
	$IPTABLES -X
	$IPTABLES -t nat -F
	# Routing
	echo 1 > /proc/sys/net/ipv4/ip_forward
	$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED,NEW -j ACCEPT
	$IPTABLES -t nat -A POSTROUTING -o eth0 -j MASQUERADE
	### ERSTELLE NEUE KETTEN ###
	# Chain to log and reject a port by ICMP port unreachable 
	$IPTABLES -N LOGREJECT 
	$IPTABLES -A LOGREJECT -m limit --limit $LOGLIMIT/minute -j LOG --log-prefix "FIREWALL REJECT " --log-level notice --log-ip-options --log-tcp-options 
	$IPTABLES -A LOGREJECT -j REJECT --reject-with icmp-port-unreachable 
	
	### PROC MANIPULATION ###
	# auf Broadcast-Pings nicht antworten
	echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
	# halt die Klappe bei komischen ICMP Nachrichten
	echo 0 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
	# Kicke den ganzen IP Spoofing Shit
	# (Source-Validierung anschalten)
	echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter
	# Setze Default-TTL auf 61 (Default fuer Linux ist 64)
	echo 61 > /proc/sys/net/ipv4/ip_default_ttl
	# sende RST-Pakete wenn der Buffer voll ist
	echo 1 > /proc/sys/net/ipv4/tcp_abort_on_overflow
	# warte max. 30 secs auf ein FIN/ACK
	echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout
	# unterbreche Verbindungsaufbau nach 3 SYN-Paketen
	# Default ist 6
	echo 3 > /proc/sys/net/ipv4/tcp_syn_retries
	# unterbreche Verbindungsaufbau nach 3 SYN/ACK-Paketen
	# Default ist 6
	echo 3 > /proc/sys/net/ipv4/tcp_synack_retries
	
	### MAIN PART ###
	$IPTABLES -P INPUT DROP
	$IPTABLES -P FORWARD DROP
	$IPTABLES -P OUTPUT ACCEPT
	$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
	$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
	# im Loopback koennen wir jedem trauen 
	$IPTABLES -A INPUT -i lo -j ACCEPT
	# ebenso im LAN
	$IPTABLES -A INPUT -i eth1 -j ACCEPT
	# erlaube Pings
	$IPTABLES -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
	# SMTP erlauben
	$IPTABLES -A INPUT -m state --state NEW -p tcp --dport 25 -j ACCEPT
	# POP3 erlauben
	$IPTABLES -A INPUT -m state --state NEW -p tcp --dport 110 -j ACCEPT
	# Webserver erlauben
	$IPTABLES -A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT

	# Alle TCP Packete, die bis hier hin kommen, werden 
        # geloggt und rejected 
        # Der Rest wird eh per Default Policy gedroppt... 
	$IPTABLES -A INPUT -p tcp -j LOGREJECT 
	$IPTABLES -A FORWARD -p tcp -j LOGREJECT
	;;
*)
	echo "Usage: `basename $0` {start}" >&2
	exit 64
	;;
esac

exit 0
- ausfuehrbar machen und mit '<skriptname> start' als root aufrufen (evtl. noch die Devices und den Pfad zu iptables anpassen, falls notwendig)

bei den Win-Rechnern
- den Router als Gateway eintragen
- IPs festlegen
- DNS deines Providers eintragen

Und dann sollte es eigentlich gehen.

//Edit: Hab den Spass jetzt noch als Mini-Howto ins Wiki gepackt: http://wiki.unixboard.de/index.php/Einrichtung_eines_einfachen_Routers_mit_Linux
 
Zuletzt bearbeitet:
@phrenicus

Ausgabe von iptables -nL ist

[root@cpc3-runc1-0-0-cust429 jau]# iptables -nL
Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0

Chain FORWARD (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain RH-Firewall-1-INPUT (2 references)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 icmp type 255
ACCEPT esp -- 0.0.0.0/0 0.0.0.0/0
ACCEPT ah -- 0.0.0.0/0 0.0.0.0/0
ACCEPT udp -- 0.0.0.0/0 224.0.0.251 udp dpt:5353
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:631
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTAB LISHED
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:2 2
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:2 5
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:8 0
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:4 43
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-ho st-prohibited
 
Ich wuerde ja in der Forward-Chain erstmal alles zulassen und die nicht dadurch begrenzen, dass du die Regeln der Input-Chain fuer die Forward nutzt.
 
Alles klar, hab folgendes ausgeführt

#!/bin/bash

## ICMP-Typen
#
# 0: echo reply (pong)
# 3: destination-unreachable (port-unreachable, fragmentation-needed etc).
# 4: source quench
# 5: redirect
# 8: echo request (ping)
# 9: router advertisement
# 10: router solicitation
# 11: time-exceeded
# 12: parameter-problem
# 13: timestamp request
# 14: timestamp reply
# 15: information request
# 16: information reply
# 17: address mask request
# 18: address mask reply

IPTABLES=`which iptables` # pfad zu iptables
DEV_EXT=eth0 # externes interface
DEV_INT=eth1 # internes interface

#limits schaffen, um DoS zu erschweren und masquerading einschalten

# einige auskommentiert, kernelspezifisch
echo "1" > /proc/sys/net/ipv4/ip_forward
echo "0" > /proc/sys/net/ipv4/tcp_syncookies
# echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
echo "0" > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
# echo "5" > /proc/sys/net/ipv4/icmp_destunreach_rate
# echo "5" > /proc/sys/net/ipv4/icmp_echoreply_rate
# echo "5" > /proc/sys/net/ipv4/icmp_paramprob_rate
# echo "10" > /proc/sys/net/ipv4/icmp_timeexceed_rate

echo "0" > /proc/sys/net/ipv4/conf/all/rp_filter
echo "0" > /proc/sys/net/ipv4/conf/eth0/rp_filter
echo "1" > /proc/sys/net/ipv4/conf/all/accept_redirects
# echo "0" > /proc/sys/net/ipv4/conf/all/accept_source_route
# echo "0" > /proc/sys/net/ipv4/conf/all/bootp_relay
echo "1" > /proc/sys/net/ipv4/conf/all/log_martians

# default-policies festlegen

$IPTABLES -P INPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -P OUTPUT ACCEPT

# laden der module für iptables-connection-tracking

modprobe ip_tables
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
modprobe ip_conntrack_irc
modprobe ip_nat_irc

# löschen aller alten evtl noch vorhandenen rules

$IPTABLES -F
$IPTABLES -t nat -F
$IPTABLES -X

# loopback muß lokal offen sein

$IPTABLES -A OUTPUT -o lo -j ACCEPT
$IPTABLES -A INPUT -i lo -j ACCEPT

# masquerading einschalten

$IPTABLES -t nat -A POSTROUTING -o $DEV_EXT -j MASQUERADE

# pakete die zu bestehenden verbindungen gehören (established)
# und solche die dazugehören (related) dürfen rein

$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# icmp rules
# type 0 echo-reply (ping)
$IPTABLES -A INPUT -p icmp --icmp-type 0 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 0 -s 0/0 -d 0/0 -j ACCEPT

# type 3 destination-unreachable (port-unreachable, fragmentation-needed
$IPTABLES -A INPUT -p icmp --icmp-type 3 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 3 -s 0/0 -d 0/0 -j ACCEPT

# type 4 source quench
$IPTABLES -A INPUT -p icmp --icmp-type 4 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 4 -s 0/0 -d 0/0 -j ACCEPT

# type 8 echo request
$IPTABLES -A INPUT -p icmp --icmp-type 8 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 8 -s 0/0 -d 0/0 -j ACCEPT

#type 11 time exceeded
$IPTABLES -A INPUT -p icmp --icmp-type 11 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 11 -s 0/0 -d 0/0 -j ACCEPT

#type 12 parameter problem
$IPTABLES -A INPUT -p icmp --icmp-type 12 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 12 -s 0/0 -d 0/0 -j ACCEPT

#type 13 timestamp request
$IPTABLES -A INPUT -p icmp --icmp-type 13 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 13 -s 0/0 -d 0/0 -j ACCEPT

#type 14 timestamp reply
$IPTABLES -A INPUT -p icmp --icmp-type 14 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 14 -s 0/0 -d 0/0 -j ACCEPT

#type 17 address mask request
$IPTABLES -A INPUT -p icmp --icmp-type 17 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 17 -s 0/0 -d 0/0 -j ACCEPT

#type 18 address mask reply
$IPTABLES -A INPUT -p icmp --icmp-type 18 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 18 -s 0/0 -d 0/0 -j ACCEPT

# ident-anfragen rejecten
$IPTABLES -A INPUT -i $DEV_EXT -p tcp --dport 113 -j REJECT --reject-with tcp-reset

# keine verbindungsanfragen an $DEV_EXT beantworten
$IPTABLES -A INPUT -m state --state NEW -i ! $DEV_EXT -j ACCEPT

# verbindungsanfragen und geblockte pakete loggen
$IPTABLES -A INPUT -i $DEV_EXT -m state --state NEW,INVALID -j LOG

# alles verwerfen, was auf keine bisherige regel gepaßt hat
$IPTABLES -A INPUT -j REJECT

und jetzt funktioniert wenigstens alles was DHCP Client ist.

Melde mich bestimmt nochmal zum Thema wenn ich mehr Zeit habe .
Vorab erstmal danke an alle.
 
Und warum nutzt du nicht einfach das Skript von oben? Damit wuerde es wahrscheinlich schon laengst laufen. *anmerk*
 
@theton

Sicherlich haette ich das tun koennen aber ich hab es nach Anleitung gemacht.
So, nun gibt es aber schonwieder ein neues Problem. Ich habe testweise mal dein Script benutzt und es ging nicht. Also alles wieder zurueck und nun geht das auch nicht mehr. Es kann nur noch daran liegen das der PATH für den Benutzer mit dem ich mich anmelde nicht gesetzt ist. Habe fuer den Benutzer den Eintrag export PATH=$PATH/:sbin gemacht.
Sollte doch das Script dass sich packetfilter.sh nennt im /sbin Verzeichniss starten oder? Rechte hab ich auf 777 gesetzt um sicher zu gehen. In der /etc/rc.local hab ich den eintrag
export PATH=$PATH:/sbin
/sbin/packetfilter.sh

Koennte ich nicht gleich alle Eintraege aus dem Script in /etc/rc.local speichern?
 
Koenntest du sicherlich auch tun, aber damit wuerdest du unnoetig die rc.local zumuellen. Du kannst das Skript auch einfach nach /etc/init.d/ kopieren, ein ordentliches init-Skript draus machen und wie alle anderen init-Skripte in die entsprechenden Runlevel verlinken.
 
Vielen dank nochmal an alle.
Das Problem lag daran das ich in der /etc/dhcpd.conf einen Dreher in der IP vom DNS Server hatte. Dohhhhhhhhh

Nur noch eine schnelle Frage bitte.
Ich will z.B. port 5000 weiterleiten an 192.168.0.100 sieht das ganze dann so richtig aus?
$IPTABLES -A FORWARD -p udp -i eth0 -o eth1 -d 192.168.0.100 --dport 5000 -j ACCEPT
Denn so scheint es nicht zu funktionieren. UDP is richtig in meinem Fall
Danke
 
Danke fuer den Link, aber selbst damit geht es nicht.
Kann hier mal jemand bitte einen Blick drauf werfen. Am Anfang des Scripts muss irgendetwas flasch sein. Meiner Meinung nach sollte das weiterleiten ins interne Netz funktionieren oder?

Ist das hier noch OK zu posten oder sollte ich ein neues Threat aufmachen.
Danke


#!/bin/bash

## ICMP-Typen
#
# 0: echo reply (pong)
# 3: destination-unreachable (port-unreachable, fragmentation-needed etc).
# 4: source quench
# 5: redirect
# 8: echo request (ping)
# 9: router advertisement
# 10: router solicitation
# 11: time-exceeded
# 12: parameter-problem
# 13: timestamp request
# 14: timestamp reply
# 15: information request
# 16: information reply
# 17: address mask request
# 18: address mask reply
export PATH=$PATH:/sbin
IPTABLES=`which iptables` # pfad zu iptables
DEV_EXT=eth0 # externes interface
DEV_INT=eth1 # internes interface

#limits schaffen, um DoS zu erschweren und masquerading einschalten

# einige auskommentiert, kernelspezifisch
echo "1" > /proc/sys/net/ipv4/ip_forward
echo "0" > /proc/sys/net/ipv4/tcp_syncookies
# echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
echo "0" > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
# echo "5" > /proc/sys/net/ipv4/icmp_destunreach_rate
# echo "5" > /proc/sys/net/ipv4/icmp_echoreply_rate
# echo "5" > /proc/sys/net/ipv4/icmp_paramprob_rate
# echo "10" > /proc/sys/net/ipv4/icmp_timeexceed_rate

echo "0" > /proc/sys/net/ipv4/conf/all/rp_filter
echo "0" > /proc/sys/net/ipv4/conf/eth0/rp_filter
echo "1" > /proc/sys/net/ipv4/conf/all/accept_redirects
# echo "0" > /proc/sys/net/ipv4/conf/all/accept_source_route
# echo "0" > /proc/sys/net/ipv4/conf/all/bootp_relay
echo "1" > /proc/sys/net/ipv4/conf/all/log_martians

# default-policies festlegen

$IPTABLES -P INPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -P OUTPUT ACCEPT

# laden der module für iptables-connection-tracking

modprobe ip_tables
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
modprobe ip_conntrack_irc
modprobe ip_nat_irc

# löschen aller alten evtl noch vorhandenen rules

$IPTABLES -F
$IPTABLES -t nat -F
$IPTABLES -X

# loopback muß lokal offen sein

$IPTABLES -A OUTPUT -o lo -j ACCEPT
$IPTABLES -A INPUT -i lo -j ACCEPT

# masquerading einschalten

$IPTABLES -t nat -A POSTROUTING -o eth0 -j MASQUERADE

# pakete die zu bestehenden verbindungen gehören (established)
# und solche die dazugehören (related) dürfen rein

$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# icmp rules
# type 0 echo-reply (ping)
$IPTABLES -A INPUT -p icmp --icmp-type 0 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 0 -s 0/0 -d 0/0 -j ACCEPT

# type 3 destination-unreachable (port-unreachable, fragmentation-needed
$IPTABLES -A INPUT -p icmp --icmp-type 3 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 3 -s 0/0 -d 0/0 -j ACCEPT

# type 4 source quench
$IPTABLES -A INPUT -p icmp --icmp-type 4 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 4 -s 0/0 -d 0/0 -j ACCEPT

# type 8 echo request
$IPTABLES -A INPUT -p icmp --icmp-type 8 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 8 -s 0/0 -d 0/0 -j ACCEPT

#type 11 time exceeded
$IPTABLES -A INPUT -p icmp --icmp-type 11 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 11 -s 0/0 -d 0/0 -j ACCEPT

#type 12 parameter problem
$IPTABLES -A INPUT -p icmp --icmp-type 12 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 12 -s 0/0 -d 0/0 -j ACCEPT

#type 13 timestamp request
$IPTABLES -A INPUT -p icmp --icmp-type 13 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 13 -s 0/0 -d 0/0 -j ACCEPT

#type 14 timestamp reply
$IPTABLES -A INPUT -p icmp --icmp-type 14 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 14 -s 0/0 -d 0/0 -j ACCEPT

#type 17 address mask request
$IPTABLES -A INPUT -p icmp --icmp-type 17 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 17 -s 0/0 -d 0/0 -j ACCEPT

#type 18 address mask reply
$IPTABLES -A INPUT -p icmp --icmp-type 18 -s 0/0 -d 0/0 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 18 -s 0/0 -d 0/0 -j ACCEPT

#mein Portforwarding
# Sh***
$IPTABLES -A INPUT -m state --state NEW -p tcp --dport 1723 -j ACCEPT
$IPTABLES -A INPUT -m state --state NEW -p tcp --dport 47 -j ACCEPT
# ftp
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 21 -j DNAT --to 192.168.0.5:21
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 20 -j DNAT --to 192.168.0.5:20
# Emule
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 4661 -j DNAT --to 192.168.0.5:4661
$IPTABLES -t nat -A PREROUTING -i eth0 -p udp --dport 4661 -j DNAT --to 192.168.0.5:4661
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 4662 -j DNAT --to 192.168.0.5:4662
$IPTABLES -t nat -A PREROUTING -i eth0 -p udp --dport 4662 -j DNAT --to 192.168.0.5:4662
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 4665 -j DNAT --to 192.168.0.5:4665
$IPTABLES -t nat -A PREROUTING -i eth0 -p udp --dport 4665 -j DNAT --to 192.168.0.5:4665
# G***
$IPTABLES -t nat -A PREROUTING -i eth0 -p udp --dport 5000 -j DNAT --to 192.168.0.100:5000
# Tja
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 7007 -j DNAT --to 192.168.0.100:7007
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 7008 -j DNAT --to 192.168.0.100:7008
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 7009 -j DNAT --to 192.168.0.100:7009
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 7010 -j DNAT --to 192.168.0.100:7010
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 7011 -j DNAT --to 192.168.0.100:7011
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 7012 -j DNAT --to 192.168.0.100:7012
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 7013 -j DNAT --to 192.168.0.100:7013
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 7014 -j DNAT --to 192.168.0.100:7014
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 7015 -j DNAT --to 192.168.0.100:7015
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 7016 -j DNAT --to 192.168.0.100:7016
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 7017 -j DNAT --to 192.168.0.100:7017
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 7018 -j DNAT --to 192.168.0.100:7018
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 7019 -j DNAT --to 192.168.0.100:7019
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 7020 -j DNAT --to 192.168.0.100:7020
# Azureus
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 52525 -j DNAT --to 192.168.0.5:52525
# Test
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 2000 -j DNAT --to 192.168.0.9:2000
# SSH
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j DNAT --to 192.168.0.5:443
# ident-anfragen rejecten
$IPTABLES -A INPUT -i $DEV_EXT -p tcp --dport 113 -j REJECT --reject-with tcp-reset

# keine verbindungsanfragen an $DEV_EXT beantworten
$IPTABLES -A INPUT -m state --state NEW -i ! $DEV_EXT -j ACCEPT

# verbindungsanfragen und geblockte pakete loggen
$IPTABLES -A INPUT -i $DEV_EXT -m state --state NEW,INVALID -j LOG

# alles verwerfen, was auf keine bisherige regel gepaßt hat
$IPTABLES -A INPUT -j REJECT


Hat sich erledigt.
Funktioniert 100% mit dem obigen Script.
Nochmal 1000 Danke and alle die geholfen haben :)
 
Zuletzt bearbeitet:
Zuerst einmal ist
Code:
$IPTABLES -A OUTPUT -o lo -j ACCEPT
total sinnlos, da du ja eh schon vorher ein
Code:
$IPTABLES -P OUTPUT ACCEPT
machst. Weiterhin ist mir unklar, warum du die ganzen ICMP-Request zulassen willst. Auch das setzen der Default-Policies vor dem entfernen der Regeln ist ziemlich ..., denn damit loescht du auch deine Default-Policies wieder, die dann per Default erstmal wieder zum DROP werden. Und ich vermisse ein
Code:
$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED,NEW -j ACCEPT
 

Ähnliche Themen

Routing mehrere Netzwerkkarten

Debian Routing Problem

Debian Gateway

OpenVPN - Server kann clients nicht erreichen.

Windows clients können nicht mehr auf lange laufendes System zugreifen

Zurück
Oben