aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: Firewall Ports  (Read 2857 times)

rambo0815

  • Newbie
  • Karma: 0
  • Offline Offline
  • Posts: 4
Firewall Ports
« on: November 30, 2005, 09:02:39 PM »

Hallihallo,

habe mal versucht meine Firewall so anzupassen, dass aMule durchgeht...allerdings muss ich fuer die Server die jeweiligen Ports freischalten, welche in der Uebersicht zu sehen sind. Sollte das nicht irgenwie mit einer einzigen Regel alles gehen?
Meine Regel:

  $IPTABLES -A INPUT -p tcp --dport 4662 -j ACCEPT
  $IPTABLES -A INPUT -p tcp --dport 4661 -j ACCEPT
  $IPTABLES -A INPUT-p udp --dport 4661 -j ACCEPT
  $IPTABLES -A INPUT -p udp --dport 4665 -j ACCEPT
  $IPTABLES -A INPUT -p udp --dport 4672 -j ACCEPT

mfg,

rrmbo
Logged

stefanero

  • Some Support
  • Developer
  • Hero Member
  • *****
  • Karma: 8
  • Offline Offline
  • Posts: 4235
Re: Firewall Ports
« Reply #1 on: November 30, 2005, 09:25:15 PM »

wozu die beiden 4661 ports?

aber die andern musst genauso durchschalten und man kann da auch nix zusammenfassen oder so...
Logged
In its default setup, Windows XP on the Internet amounts to a car
parked in a bad part of town, with the doors unlocked, the key in
the ignition and a Post-It note on the dashboard saying, "Please
don't steal this."

rambo0815

  • Newbie
  • Karma: 0
  • Offline Offline
  • Posts: 4
Re: Firewall Ports
« Reply #2 on: November 30, 2005, 10:13:56 PM »

Naja, wenn ich die 4661er nicht drin hab, bekomm ich keine Verbindung. Es gibt ein paar Server, bei denen steht in aMule was von Port 4661.
Logged

stefanero

  • Some Support
  • Developer
  • Hero Member
  • *****
  • Karma: 8
  • Offline Offline
  • Posts: 4235
Re: Firewall Ports
« Reply #3 on: November 30, 2005, 10:26:09 PM »

das sind aber die server ports die sind normalerweise die ports die DIE freischalten müssen, das hat mit deinen firewall einstellungen eigentlich nix zu tun...

wichtig sind die ports die in deinen aMule-einstellungen stehen also

TCP-port
UDP-port
TCP+3 als udp

mehr brauchst normalerweise eigentlich net ....
Logged
In its default setup, Windows XP on the Internet amounts to a car
parked in a bad part of town, with the doors unlocked, the key in
the ignition and a Post-It note on the dashboard saying, "Please
don't steal this."

rambo0815

  • Newbie
  • Karma: 0
  • Offline Offline
  • Posts: 4
Re: Firewall Ports
« Reply #4 on: November 30, 2005, 10:57:01 PM »

OK, dann scheint mein Rechner unnormal zu sein. Das PProblem ist allllso nicht           bekannt? Keine Loesungsidee?

mfg,

Rrmbo
Logged

stefanero

  • Some Support
  • Developer
  • Hero Member
  • *****
  • Karma: 8
  • Offline Offline
  • Posts: 4235
Re: Firewall Ports
« Reply #5 on: December 01, 2005, 07:33:09 AM »

poste doch mal das complete firewall script..vielleicht leigt ja der fehler woanders...
nur wie gesagt normal is das net ;)
Logged
In its default setup, Windows XP on the Internet amounts to a car
parked in a bad part of town, with the doors unlocked, the key in
the ignition and a Post-It note on the dashboard saying, "Please
don't steal this."

rambo0815

  • Newbie
  • Karma: 0
  • Offline Offline
  • Posts: 4
Firewall script
« Reply #6 on: December 01, 2005, 09:28:15 PM »

Hier waere men Firewall Script:

#!/sbin/runscript
IPTABLES=/sbin/iptables
IPTABLESSAVE=/sbin/iptables-save
IPTABLESRESTORE=/sbin/iptables-restore
IINTERFACE=eth0
FIREWALL=/etc/firewall.rules

opts="${opts} showstatus panic save restore showoptions rules"

depend() {
  need net
}

rules() {
  stop
  ebegin "Setze interne Regeln"

  einfo "Setze Standardregel auf fallenlassen"
  $IPTABLES -P FORWARD DROP
  $IPTABLES -P INPUT   DROP
  $IPTABLES -P OUTPUT  DROP

  #Standardregel
  einfo "Erstelle Zustands-Kette"
  $IPTABLES -N allowed-connection
  $IPTABLES -F allowed-connection
  $IPTABLES -A allowed-connection -m state --state ESTABLISHED,RELATED -j ACCEPT
  $IPTABLES -A allowed-connection -i $IINTERFACE -m limit -j LOG --log-prefix \
      "Bad packet from ${IINTERFACE}:"
  $IPTABLES -A allowed-connection -j DROP

  #aMule
  $IPTABLES -N amule_allowed
  $IPTABLES -F amule_allowed
  $IPTABLES -A amule_allowed -p tcp --dport 4662 -j ACCEPT
  $IPTABLES -A amule_allowed -p tcp --dport 4661 -j ACCEPT
  $IPTABLES -A amule_allowed -p udp --dport 4661 -j ACCEPT
  $IPTABLES -A amule_allowed -p udp --dport 4665 -j ACCEPT
  $IPTABLES -A amule_allowed -p udp --dport 4672 -j ACCEPT

  #ICMP Verkehr
  einfo "Erstelle ICMP-Kette"
  $IPTABLES -N icmp_allowed
  $IPTABLES -F icmp_allowed
  #$IPTABLES -A icmp_allowed -p icmp -j DROP
  $IPTABLES -A icmp_allowed -m state --state NEW -p icmp --icmp-type time-exceeded -j ACCEPT
  $IPTABLES -A icmp_allowed -m state --state NEW -p icmp --icmp-type destination-unreachable -j ACCEPT
  $IPTABLES -A icmp_allowed -m state --state NEW -p icmp --icmp-type echo-request -j ACCEPT
  #$IPTABLES -A icmp_allowed -m state --state NEW -p icmp --icmp-type echo-reply -j ACCEPT
  $IPTABLES -A icmp_allowed -p icmp -j LOG --log-prefix "Bad ICMP traffic:"

  #Eingehender Verkehr
  einfo "Erstelle Kette fuer eingehenden SSH-Verkehr"
  $IPTABLES -N allow-ssh-traffic-in
  $IPTABLES -F allow-ssh-traffic-in
  #Flood-Schutz
  $IPTABLES -A allow-ssh-traffic-in -m limit --limit 1/second -p tcp --tcp-flags ALL RST --dport ssh -j ACCEPT
  $IPTABLES -A allow-ssh-traffic-in -m limit --limit 1/second -p tcp --tcp-flags ALL FIN --dport ssh -j ACCEPT
  $IPTABLES -A allow-ssh-traffic-in -m limit --limit 1/second -p tcp --tcp-flags ALL SYN --dport ssh -j ACCEPT
  $IPTABLES -A allow-ssh-traffic-in -m state --state RELATED,ESTABLISHED -p tcp --dport ssh -j ACCEPT

 #Ausgehender Verkehr
  einfo "Erstelle Kette fuer ausgehenden SSH-Verkehr"
  $IPTABLES -N allow-ssh-traffic-out
  $IPTABLES -F allow-ssh-traffic-out
  $IPTABLES -A allow-ssh-traffic-out -p tcp --dport ssh -j ACCEPT

  einfo "Erstelle Kette fuer ausgehenden DNS-Verkehr "
  $IPTABLES -N allow-dns-traffic-out
  $IPTABLES -F allow-dns-traffic-out
  $IPTABLES -A allow-dns-traffic-out -p udp --dport domain -j ACCEPT
  #$IPTABLES -A allow-dns-traffic-out -p udp -d $DNS2 --dport domain -j ACCEPT

  einfo "Erstelle Kette fuer ausgehenden http/https Verkehr"
  $IPTABLES -N allow-www-traffic-out
  $IPTABLES -F allow-www-traffic-out
  $IPTABLES -A allow-www-traffic-out -p tcp --dport www -j ACCEPT
  $IPTABLES -A allow-www-traffic-out -p tcp --dport https -j ACCEPT
  $IPTABLES -A allow-www-traffic-out -p tcp --dport 873 -j ACCEPT #rsync
  $IPTABLES -A allow-www-traffic-out -p tcp --dport ftp -j ACCEPT #ftp

  #Portscanner fangen
  einfo "Erstelle Portscan-Erkennungs-Kette"
  $IPTABLES -N check-flags
  $IPTABLES -F check-flags
  $IPTABLES -A check-flags -p tcp --tcp-flags ALL FIN,URG,PSH -m limit --limit 5/minute -j LOG --log-level alert --log-prefix "NMAP-XMAS:"
  $IPTABLES -A check-flags -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
  $IPTABLES -A check-flags -p tcp --tcp-flags ALL ALL -m limit --limit 5/minute -j LOG --log-level 1 --log-prefix "XMAS:"
  $IPTABLES -A check-flags -p tcp --tcp-flags ALL ALL -j DROP
  $IPTABLES -A check-flags -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -m limit --limit 5/minute -j LOG --log-level 1 --log-prefix "XMAS-PSH:"
  $IPTABLES -A check-flags -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
  $IPTABLES -A check-flags -p tcp --tcp-flags ALL NONE -m limit --limit 5/minute -j LOG --log-level 1 --log-prefix "NULL_SCAN:"
  $IPTABLES -A check-flags -p tcp --tcp-flags ALL NONE -j DROP
  $IPTABLES -A check-flags -p tcp --tcp-flags SYN,RST SYN,RST -m limit --limit 5/minute -j LOG --log-level 5 --log-prefix "SYN/RST:"
  $IPTABLES -A check-flags -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
  $IPTABLES -A check-flags -p tcp --tcp-flags SYN,FIN SYN,FIN -m limit --limit 5/minute -j LOG --log-level 5 --log-prefix "SYN/FIN:"
  $IPTABLES -A check-flags -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP

  # Ungueltige Zustaende in den Ketten einpassen
  einfo "Passe Ketten in INPUT an"
  $IPTABLES -A INPUT -m state --state INVALID -j DROP
  $IPTABLES -A INPUT -j icmp_allowed
  $IPTABLES -A INPUT -j amule_allowed
  $IPTABLES -A INPUT -j check-flags
  $IPTABLES -A INPUT -i lo -j ACCEPT
  $IPTABLES -A INPUT -j allow-ssh-traffic-in
  $IPTABLES -A INPUT -j allowed-connection

  einfo "Passe Ketten in FORWARD an"
  $IPTABLES -A FORWARD -m state --state INVALID -j DROP
  $IPTABLES -A FORWARD -j icmp_allowed
  $IPTABLES -A FORWARD -j check-flags
  $IPTABLES -A FORWARD -o lo -j ACCEPT
  $IPTABLES -A FORWARD -j allow-ssh-traffic-in
  $IPTABLES -A FORWARD -j allow-www-traffic-out
  $IPTABLES -A FORWARD -j allowed-connection

  einfo "Passe Ketten in OUTPUT an"
  $IPTABLES -A OUTPUT -m state --state INVALID -j DROP
  $IPTABLES -A OUTPUT -j icmp_allowed
  $IPTABLES -A OUTPUT -j check-flags
  $IPTABLES -A OUTPUT -j amule_allowed
  $IPTABLES -A OUTPUT -o lo -j ACCEPT
  $IPTABLES -A OUTPUT -j allow-ssh-traffic-out
  $IPTABLES -A OUTPUT -j allow-dns-traffic-out
  $IPTABLES -A OUTPUT -j allow-www-traffic-out
  $IPTABLES -A OUTPUT -j allowed-connection

  #erlaube den Clients ueber NAT (Network Address Translation) zu routen
  #$IPTABLES -t nat -A POSTROUTING -o $IINTERFACE -j MASQUERADE
  eend $?
}

start() {
  ebegin "Starte firewall"
  if [ -e "${FIREWALL}" ]; then
    restore
  else
    einfo "${FIREWALL} existiert nicht. Benutze Standardregeln."
    rules
  fi
  eend $?
}

stop() {
  ebegin "Halte Firewall an"
  $IPTABLES -F
  $IPTABLES -t nat -F
  $IPTABLES -X
  $IPTABLES -P FORWARD ACCEPT
  $IPTABLES -P INPUT   ACCEPT
  $IPTABLES -P OUTPUT  ACCEPT
  eend $?
}

showstatus() {
  ebegin "Status"
  $IPTABLES -L -n -v --line-numbers
  einfo "NAT status"
  $IPTABLES -L -n -v --line-numbers -t nat
  eend $?
}

panic() {
  ebegin "Setze Panikregeln"
  $IPTABLES -F
  $IPTABLES -X
  $IPTABLES -t nat -F
  $IPTABLES -P FORWARD DROP
  $IPTABLES -P INPUT   DROP
  $IPTABLES -P OUTPUT  DROP
  $IPTABLES -A INPUT -i lo -j ACCEPT
  $IPTABLES -A OUTPUT -o lo -j ACCEPT
  eend $?
}
 
save() {
  ebegin "Sichere Firewallregeln"
  $IPTABLESSAVE > $FIREWALL
  eend $?
}

restore() {
  ebegin "Stelle Firewallregeln wieder her"
  $IPTABLESRESTORE < $FIREWALL
  eend $?
}

restart() {
  svc_stop; svc_start
}


showoptions() {
  echo "Usage: $0 {start|save|restore|panic|stop|restart|showstatus}"
  echo "start      wird die Standardeinstellung wieder herstellen oder andernfalls zu Regeln zwingen"
  echo "stop       alle Regeln lschen und alles akzeptieren"
  echo "rules      Einstellungen der neuen regeln erzwingen"
  echo "save       speichert die Regeln in ${FIREWALL}"
  echo "restore    stellt die Regeln von ${FIREWALL} wieder her"
  echo "showstatus Status anzeigen"
}

Ich habs von irgendwo aus dem Netz und ein wenig modifiziert...
Logged