OVH Community, your new community space.

x2go iptables problem


echoslider
20.07.11, 12:19
hm ne. also irgendwie sieht man da nix mit dem -v parameter. ja klar. ohne iptables. also firewall aus. da gehts.

hier nochmal was wenn die verbindung ohne iptables klappt:

Code:
NXPROXY - Version 3.4.0

Copyright (C) 2001, 2007 NoMachine.
See http://www.nomachine.com/ for more information.

Info: Proxy running in client mode with pid '12544'.
Session: Starting session at 'Wed Jul 20 13:14:16 2011'.
Info: Connecting to remote host 'localhost:30049'.
Info: Connection to remote proxy 'localhost:30049' established.
Error: The remote NX proxy closed the connection.
Error: Failure negotiating the session in stage '7'.
Error: Wrong version or invalid session authentication cookie.
Session: Terminating session at 'Wed Jul 20 13:14:16 2011'.
Session: Session terminated at 'Wed Jul 20 13:14:16 2011'.
Zeitüberschreitung
NXPROXY - Version 3.4.0

Copyright (C) 2001, 2007 NoMachine.
See http://www.nomachine.com/ for more information.

Info: Proxy running in client mode with pid '11456'.
Session: Starting session at 'Wed Jul 20 13:15:04 2011'.
Info: Connecting to remote host 'localhost:30058'.
Info: Connection to remote proxy 'localhost:30058' established.
Warning: Connected to remote version 3.5.0 with local version 3.4.0.
Warning: Consider checking http://www.nomachine.com/ for updates.
Info: Connection with remote proxy completed.
Warning: Unrecognized session type 'unix-kde-depth_32'. Assuming agent session.
Warning: Failed to read data from the X auth command.
Warning: Generated a fake cookie for X authentication.
Info: Using ADSL link parameters 512/24/1/0.
Info: Using cache parameters 4/4096KB/8192KB/8192KB.
Info: Using pack method '16m-jpeg-9' with session 'unix-kde-depth_32'.
Info: Using ZLIB data compression 1/1/32.
Info: Using ZLIB stream compression 4/4.
Info: No suitable cache file found.
Info: Forwarding X11 connections to display 'localhost:1'.
Session: Session started at 'Wed Jul 20 13:15:05 2011'.
Info: Established X server connection.
Info: Using shared memory parameters 0/0K.

und wenn iptables aktiv sind würde es nur bis...

Code:
Info: Proxy running in client mode with pid '11456'.
Session: Starting session at 'Wed Jul 20 13:15:04 2011'.
Info: Connecting to remote host 'localhost:30058'.
Info: Connection to remote proxy 'localhost:30058' established.
gehen. ich weiß echt nicht mehr weiter. nur da da ändert sich immer der port zu jeder neuen session.


---------------------------------------------------------------
ok. danke. hab nochmal alles überarbeitet mit den regeln. war gut was du meintest das die regeln von knockd an den anfang sollten. nun geht es. danke.

Isondolos
20.07.11, 11:40
"the remote proxy closed the connection while negotiating the session. this may be due to the wrong authentication credentials passed to the server."
klingt eher nach falschem Passwort.

Funktioniert x2go denn bei komplett offener firewall?

Kannst ja noch iptables -L -v nutzen um rauszufinden, welche Regel wie oft gegriffen hat. Also absetzen, x2go bemühen, nochmal absetzen und vergleichen.

echoslider
20.07.11, 11:14
Code:
/sbin/iptables -I INPUT -s %IP% -j ACCEPT
so das habe ich in knockd eingefügt.

hat aber bei x2go nicht geholfen...
Code:
Info: Proxy running in client mode with pid '8540'.
Session: Starting session at 'Wed Jul 20 12:09:35 2011'.
Info: Connecting to remote host 'localhost:30040'.
Info: Connection to remote proxy 'localhost:30040' established.
kommt da. so wie sonst immer. und irgend wann später kommt auch wie immer

Code:
the remote proxy closed the connection while negotiating the session. this may be due to the wrong authentication credentials passed to the server.
hat leider nicht geholfen...

ich hab da noch ein paar logs gefunden nur kp ob die helfen... und wie man die behebt bei meiner firewall weiß ich auch nicht da ja eigendlich alles erlaubt sein sollte von innen nach außen. also auch was mit localhost?!...

Code:
Jul 20 12:28:00 ns383099 sshd[26548]: reverse mapping checking getaddrinfo for dslc-082-082-083-032.pools.arcor-ip.net [82.82.83.32] failed - POSSIBLE BREAK-IN ATTEMPT!
Jul 20 12:28:00 ns383099 sshd[26548]: Accepted password for echoslider from 82.82.83.32 port 5999 ssh2
Jul 20 12:28:00 ns383099 sshd[26548]: pam_unix(sshd:session): session opened for user echoslider by (uid=0)
Jul 20 12:28:01 ns383099 CRON[27005]: pam_unix(cron:session): session opened for user root by (uid=0)
Jul 20 12:28:01 ns383099 CRON[27005]: pam_unix(cron:session): session closed for user root
Jul 20 12:28:03 ns383099 sshd[27004]: error: connect_to localhost port 30049: failed.

Isondolos
20.07.11, 10:41
Moin,

Iptables geht sequenziell von oben nach unten druch.

iptables -A ....
fügt am ENDE der Liste eine Regel an.

probier mal stattdessen iptables -I .... das fügt die neue Regel am Anfang ein.

echoslider
20.07.11, 10:21
hallo.
habe x2go installiert. die verbindungen klappen auch alle. nur nicht mit meinen iptables... was ist falsch? anscheinend klappt da was nicht mit dem ssh tunnel. wie man das beheben kann weiß ich aber nicht.

ach der ssh port 22 wird auch freigegeben. über knockd. das funktioniert ohne probleme. freigegeben wird das mit ...

Code:
/sbin/iptables -A INPUT -s %IP% -j ACCEPT
... was ja eigendlich alles frei geben sollte. von X IP.

... die firewall:

Code:
#!/bin/sh




IPT=/sbin/iptables

interface='eth0'
ping='1'
trace='0'



case "$1" in
start)

$IPT -t nat -F
$IPT -t filter -F
$IPT -X
$IPT -P INPUT DROP
$IPT -P OUTPUT ACCEPT
$IPT -P FORWARD ACCEPT

# über Loopback alles erlauben
$IPT -I INPUT -i lo -j ACCEPT
$IPT -I OUTPUT -o lo -j ACCEPT

$IPT -A INPUT -i $interface -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A INPUT -i $interface -p icmp --source proxy.ovh.net -j ACCEPT
$IPT -A INPUT -i $interface -p icmp --source proxy.p19.ovh.net -j ACCEPT
$IPT -A INPUT -i $interface -p icmp --source proxy.rbx.ovh.net -j ACCEPT
$IPT -A INPUT -i $interface -p icmp --source proxy.rbx2.ovh.net -j ACCEPT
$IPT -A INPUT -i $interface -p icmp --source proxy.rbx3.ovh.net -j ACCEPT
$IPT -A INPUT -i $interface -p icmp --source a2.ovh.net -j ACCEPT
$IPT -A INPUT -i $interface -p icmp --source ping.ovh.net -j ACCEPT
$IPT -A INPUT -i $interface -p tcp --source 192.168.0.0/16 -j ACCEPT
$IPT -A INPUT -i $interface -p udp --source 192.168.0.0/16 -j ACCEPT
$IPT -A INPUT -i $interface -p tcp --dport 79 -j ACCEPT

$IPT -A INPUT -i $interface -p tcp --dport 80 -j ACCEPT


#####################################################
# Erweiterte Sicherheitsfunktionen

#anti PortScan
$IPT -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT

$IPT -I INPUT -p tcp -m state --state NEW -s 0.0.0.0/0 -m recent --set
$IPT -I INPUT -p tcp -m state --state NEW -s 0.0.0.0/0 -m recent --update --seconds 10 --hitcount 5 -j DROP
$IPT -I INPUT -p udp -m state --state NEW -s 0.0.0.0/0 -m recent --set
$IPT -I INPUT -p udp -m state --state NEW -s 0.0.0.0/0 -m recent --update --seconds 10 --hitcount 5 -j DROP

#anti smurf
$IPT -A INPUT -p tcp -m tcp --tcp-flags RST RST -m limit --limit 2/second --limit-burst 2 -j ACCEPT

# Ping-of-Death
$IPT -A FORWARD -p icmp --icmp-type 8 -m limit --limit 1/s -j ACCEPT

#Limiting the incoming icmp ping request:
if [ $ping -eq "1" ]; then

$IPT -I INPUT -p icmp --icmp-type echo-request -m recent --set
$IPT -I INPUT -p icmp --icmp-type echo-request -m recent --update --seconds 6 --hitcount 3 -j DROP
$IPT -A INPUT -p icmp --icmp-type echo-request -j ACCEPT

fi


#traceroute erlauben
if [ $trace -eq "1" ]; then

$IPT -A INPUT -p ICMP --icmp-type 11 -s 0.0.0.0/0 -j ACCEPT

fi

# SYN und RST gleichzeitig gesetzt
$IPT -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
$IPT -A FORWARD -p tcp --tcp-flags SYN,RST SYN,RST -j DROP

# SYN und FIN gesetzt
$IPT -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
$IPT -A FORWARD -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP

#fin und urg und psh gesetzt
$IPT -A INPUT -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
$IPT -A FORWARD -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP

#all syn
$IPT -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
$IPT -A FORWARD -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP

#all
$IPT -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
$IPT -A FORWARD -p tcp --tcp-flags ALL ALL -j DROP

#Keine Flags gesetzt nmap 0 scan
$IPT -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
$IPT -A FORWARD -p tcp --tcp-flags ALL NONE -j DROP

#nmap fin stealth scan
$IPT -A INPUT -p tcp --tcp-flags ALL FIN -j DROP
$IPT -A FORWARD -p tcp --tcp-flags ALL FIN -j DROP

#xmas
$IPT -A INPUT -p tcp --tcp-flags ALL URG,ACK,PSH,RST,SYN,FIN -j DROP
$IPT -A FORWARD -p tcp --tcp-flags ALL URG,ACK,PSH,RST,SYN,FIN -j DROP

# FIN und RST gleichzeitig gesetzt
$IPT -A INPUT -p tcp --tcp-flags FIN,RST FIN,RST -j DROP
$IPT -A FORWARD -p tcp --tcp-flags FIN,RST FIN,RST -j DROP

# FIN ohne ACK
$IPT -A INPUT -p tcp --tcp-flags ACK,FIN FIN -j DROP
$IPT -A FORWARD -p tcp --tcp-flags ACK,FIN FIN -j DROP

# PSH ohne ACK
$IPT -A INPUT -p tcp --tcp-flags ACK,PSH PSH -j DROP
$IPT -A FORWARD -p tcp --tcp-flags ACK,PSH PSH -j DROP

# URG ohne ACK
$IPT -A INPUT -p tcp --tcp-flags ACK,URG URG -j DROP
$IPT -A FORWARD -p tcp --tcp-flags ACK,URG URG -j DROP

# SYN-Flood-Schutz
$IPT -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT

# Forwarding/Routing
echo 1 > /proc/sys/net/ipv4/ip_forward 2> /dev/null

#Masquerading
$IPT -t nat -A POSTROUTING -o $interface -j MASQUERADE

#SYN-Cookies
echo 1 > /proc/sys/net/ipv4/tcp_syncookies 2> /dev/null

#Stop Source-Routing
for i in /proc/sys/net/ipv4/conf/*; do echo 0 > $i/accept_source_route 2> /dev/null; done

#Stop Redirecting
for i in /proc/sys/net/ipv4/conf/*; do echo 0 > $i/accept_redirects 2> /dev/null; done

#Reverse-Path-Filter
for i in /proc/sys/net/ipv4/conf/*; do echo 2 > $i/rp_filter 2> /dev/null; done

#Log Martians
for i in /proc/sys/net/ipv4/conf/*; do echo 1 > $i/log_martians 2> /dev/null; done

#BOOTP-Relaying ausschalten
for i in /proc/sys/net/ipv4/conf/*; do echo 0 > $i/bootp_relay 2> /dev/null; done

#Proxy-ARP ausschalten
for i in /proc/sys/net/ipv4/conf/*; do echo 0 > $i/proxy_arp 2> /dev/null; done

#Ungültige ICMP-Antworten ignorieren
echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses 2> /dev/null

#ICMP Echo-Broadcasts ignorieren
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts 2> /dev/null

#Max. 500/Sekunde (5/Jiffie) senden
echo 5 > /proc/sys/net/ipv4/icmp_ratelimit

#Speicherallozierung und -timing für IP-De/-Fragmentierung
echo 262144 > /proc/sys/net/ipv4/ipfrag_high_thresh
echo 196608 > /proc/sys/net/ipv4/ipfrag_low_thresh
echo 30 > /proc/sys/net/ipv4/ipfrag_time

#TCP-FIN-Timeout zum Schutz vor DoS-Attacken setzen
echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout

#Maximal 3 Antworten auf ein TCP-SYN
echo 3 > /proc/sys/net/ipv4/tcp_retries1

#TCP-Pakete maximal 15x wiederholen
echo 15 > /proc/sys/net/ipv4/tcp_retries2




exit 0
;;

stop)
$IPT -t nat -F
$IPT -t filter -F
$IPT -X
$IPT -P INPUT ACCEPT
$IPT -P OUTPUT ACCEPT
$IPT -P FORWARD ACCEPT
exit 0
;;
*)
echo "Usage: /etc/init.d/firewall {start|stop}"
exit 1
;;
esac