openvpn megorjit

Fórumok

Sziasztok,

Kezdek begolyozni.

A szitu a kovetkezo. Van egy ubuntu 9.04 server rajta, OpenVPN 2.1_rc19 i686-pc-linux-gnu [SSL] [LZO2] [EPOLL] built on Apr 6 2010

Be volt allitva rajta minden , mukodott is rendesen. Semmi nem valtozott rajta elvileg.
De most nem akarodzik rendesen dolgozni.
Illetve a tunelt felepiti , a kliens kap ipcimet de a forgalom nem megy rajta.
A tuzfal nem valltozott .
Mar vegigturtam a netet de nem jovok ra , h mi a hiba.

Kerlek segitsetek !
Milyen conf-ot , logot kuldjek ?

Koszi

Sztupi

Hozzászólások

routeok jók? Ha tcpdumpolsz a két végén, látsz forgalmat?

"A" gép: 1.1.1.1, "B" gép: 2.2.2.2
A-n: ip route get 2.2.2.2 mit mond?
B-n: ip route get 1.1.1.1 mit mond?

ifconfig mit mond? Van forgalom az interfészen?

iptables -Lv:
Chain INPUT (policy DROP 6086 packets, 1334K bytes)
pkts bytes target prot opt in out source destination
16 1648 REJECT icmp -- any any anywhere anywhere reject-with icmp-port-unreachable
0 0 ACCEPT all -- lo any anywhere anywhere
0 0 ACCEPT tcp -- any any anywhere anywhere state NEW tcp dpt:openvpn
2 84 ACCEPT udp -- any any anywhere anywhere state NEW udp dpt:openvpn
8287 473K ACCEPT tcp -- any any anywhere anywhere tcp dpt:ssh
0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:ssh
340 30731 ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED
0 0 SSHSCAN tcp -- eth0 any anywhere anywhere tcp dpt:ssh state NEW
0 0 ACCEPT tcp -- eth0 any anywhere anywhere state NEW tcp dpt:ssh

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- tun0 any 10.80.1.0/24 localnet/24

Chain OUTPUT (policy ACCEPT 13651 packets, 3830K bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- any lo anywhere anywhere

Chain SSHSCAN (1 references)
pkts bytes target prot opt in out source destination
0 0 all -- any any anywhere anywhere recent: SET name: SSH side: source
0 0 LOG all -- any any anywhere anywhere recent: UPDATE seconds: 120 hit_count: 3 name: SSH side: source LOG level debug prefix `SSH SCAN blocked: '
0 0 DROP all -- any any anywhere anywhere recent: UPDATE seconds: 120 hit_count: 3 name: SSH side: source

Server :
ifconfig:
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.80.0.1 P-t-P:10.80.0.2 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
route:
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.80.0.2 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
10.80.0.0 10.80.0.2 255.255.255.0 UG 0 0 0 tun0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

tcpdump -i tun0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on tun0, link-type RAW (Raw IP), capture size 96 bytes
^C
0 packets captured
0 packets received by filter
0 packets dropped by kernel

Kliens
ifconfig:
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.80.0.6 P-t-P:10.80.0.5 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
route:
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.80.0.5 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0

/etc/init.d# tcpdump -i tun0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on tun0, link-type RAW (Raw IP), capture size 96 bytes
^C
0 packets captured
0 packets received by filter
0 packets dropped by kernel



Chain INPUT (policy DROP 6086 packets, 1334K bytes)
pkts bytes target prot opt in out source destination
16 1648 REJECT icmp -- any any anywhere anywhere reject-with icmp-port-unreachable
0 0 ACCEPT all -- lo any anywhere anywhere
0 0 ACCEPT tcp -- any any anywhere anywhere state NEW tcp dpt:openvpn
2 84 ACCEPT udp -- any any anywhere anywhere state NEW udp dpt:openvpn
8287 473K ACCEPT tcp -- any any anywhere anywhere tcp dpt:ssh
0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:ssh
340 30731 ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED
0 0 SSHSCAN tcp -- eth0 any anywhere anywhere tcp dpt:ssh state NEW
0 0 ACCEPT tcp -- eth0 any anywhere anywhere state NEW tcp dpt:ssh--

Én ebben sehol sem látom, hogy a tunel-ről jövő csomagokat elfogadnád... pont ellenkezőleg... eldobtál már 6086 csomagot...

De még más hibák is lehetnek... :D

Debian Linux rulez... :D

na igen de men igazan ertem mert a tuzfal nem valtozott,

Itt
a tuzfal szabaly lista:
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X

iptables -P INPUT DROP
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

# ICMP REJECT ( ping, etc )
iptables -A INPUT -p icmp -j REJECT

# Accept lo ( loopback interface )
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

# HTTP
#iptables -A INPUT -p tcp --dport 80 -j ACCEPT
#iptables -A INPUT -p udp --dport 80 -j ACCEPT

# E-mail ( pop3, smtp, spop3 )
#iptables -A INPUT -p tcp -m multiport --dports 25,110,995 -j ACCEPT

# OpenVPN
iptables -A INPUT -m state --state NEW -p tcp --dport 1194 -j ACCEPT
iptables -A INPUT -m state --state NEW -p udp --dport 1194 -j ACCEPT

# DNS
#iptables -A INPUT -p tcp --dport 53 -j ACCEPT
#iptables -A INPUT -p udp --dport 53 -j ACCEPT

# INETD
#iptables -A INPUT -p tcp --dport 113 -j ACCEPT

# SSHD
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p udp --dport 22 -j ACCEPT

iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

# Intranet Sharing. Masquerading VPN traffic to eth0 interface
iptables -t nat -A POSTROUTING -s 10.80.0.0/24 -o eth0 -j MASQUERADE

# esetleg meg ez is kell
iptables -A FORWARD -i tun0 -s 10.80.1.0/24 -d 192.168.1.0/24 -j ACCEPT

## Védekezzünk ##
iptables -N SSHSCAN
iptables -A INPUT -i eth0 -p tcp --dport 22 -m state --state NEW -j SSHSCAN
iptables -A SSHSCAN -m recent --set --name SSH

# SSH Brute force támadás loggolása #
iptables -A SSHSCAN -m recent --update --seconds 120 --hitcount 3 --name SSH -j LOG --log-level debug --log-prefix "SSH SCAN blocked: "
iptables -A SSHSCAN -m recent --update --seconds 120 --hitcount 3 --name SSH -j DROP
iptables -A INPUT -i eth0 -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT

# Enabling IP-Forwarding
echo "1" > /proc/sys/net/ipv4/ip_forward

ebben milyen hibat latsz ? mert en nezem de nem latom

# ICMP REJECT ( ping, etc )
iptables -A INPUT -p icmp -j REJECT

Minden ICMP-t ki akarsz zárni?

# Intranet Sharing. Masquerading VPN traffic to eth0 interface
iptables -t nat -A POSTROUTING -s 10.80.0.0/24 -o eth0 -j MASQUERADE

# esetleg meg ez is kell
iptables -A FORWARD -i tun0 -s 10.80.1.0/24 -d 192.168.1.0/24 -j ACCEPT

Ez szerintem nem kell... Forward akkor kell, ha elhagyja a szervert a csomag...

A MASQUERADE egyszerűbben is mehetne...
iptables -t nat -j MASQUERADE -o eth0

A tun-on meg engedj be mindent első körben...
iptables -t filter -j ACCEPT -i tun0

Server - ifconfig:
inet addr:10.80.0.1 P-t-P:10.80.0.2 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1

Kliens - ifconfig:
inet addr:10.80.0.6 P-t-P:10.80.0.5 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1

Ezt biztos így akartad??? Ez most ptp vagy subnet?

--
Debian Linux rulez... :D

a forward sort kivettem
"Ezt biztos így akartad??? Ez most ptp vagy subnet?"
igazabol azt akartam , h a belso halohoz barhonnan lehessen csatlakozni ha meg vannak a megfelelo kulcsok +crt-k
ill. meg egy szandekom van : az hogy csak egy gep 1494-es portjat erjek el (ez lenne egy PREROUTING lanc)ill MAC alapjan nehany gep barmit.
De ezeket a szabalyokat meg ne irtam bele a tuzfalba , majd ha elindul akkor faragom tovabb.

Na akkor kezdjük elölről.... :D

a, A gépek gondolom kívülről (WAN irányból) fognak kapcsolódni.
Ehhez a VPN szerver tcp vagy udp (javasolt) portját (1194 vagy amit beállítasz) kell átengedni a tűzfalon

b, OpenVPN alatt lehet kapcsolódni tun illetve tap eszközzel. Tun esetén p2p lesz a hálózat, tap esetén lehet subnet.

tun:
Szerver: 10.0.0.1 netmask: 255.255.255.255 (10.0.0.1/32) ptp: 10.0.0.2
Kliens: 10.0.0.2 netmask: 255.255.255.255 (10.0.0.2/32) ptp: 10.0.0.1

tap
Szerver: 10.0.0.1 netmask: 255.255.255.0 (10.0.0.1/24)
Kliens: 10.0.0.2 netmask 255.255.255.0 (10.0.0.2/24)
(Ez a 10.0.0.0/24-es háló)

c, Ezzel még csak csatlakoztál a szerverhez!!! Ha kell, akkor bridge-elheted a tun/tap interfészt a lan interfészhez.

d, A kliensek MAC címe OpenVPN alatt 00:FF-el kezdődik !!! (Ezt jól fel lehet használni.) És persze át is lehet írni.

e, Használhatsz DHCP szervert a címek kiosztására egyaránt lan-ban, tun/tap-ban, bridge-ben!!!

Én ilyen rendszeren dolgozok. Ha kell segítség szólj.

Egy szerverkonfig:

dev vpn1
dev-type tap
proto udp
port 11940
mode server

ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/server.crt
key /etc/openvpn/keys/server.key
dh /etc/openvpn/keys/dh2048.pem
tls-auth /etc/openvpn/keys/ta.key 0
tls-server

status /var/log/openvpn1.status 1
log-append /var/log/openvpn1.log
verb 3
mute 20

client-config-dir ccd/1
client-to-client
keepalive 10 60
cipher AES-256-CBC

script-security 2
up /etc/openvpn/tap1-up
down-pre /etc/openvpn/tap1-down
ifconfig-nowarn

comp-lzo yes
float
tun-mtu 1500
fragment 1400
mssfix 1400
passtos
txqueuelen 10000

(Ha csak másolod értelmezés nélkül, akkor nem fog működni... :D )

--
Debian Linux rulez... :D

Koszi az infokat.

Tehat en tunelt hasznalok. Fel is epul kiosztja az ipcimeket is csak a epp nem tudok csatlakozni a belso gepekhez.
Sejtesem szerint ez vmi tuzfal gond lehet .
Az erdekes az , h eddig mukodott az openvpn es egyszer tortent vmi es lehalt.

A kollegaim eskusznek , h nem nyultak bele , s en sem latom , h vmi valtozott volna.
Ezzel kuzdok egy ideje.

elkuldom a configokat esetleg ha abban latsz vmit.

Server:

mode server
tls-server
port 1194
proto udp
dev tun
topology subnet
ca /etc/openvpn/server/ca.crt
cert /etc/openvpn/server/vpnserver.crt
key /etc/openvpn/server/vpnserver.key
dh /etc/openvpn/server/dh2048.pem
server 10.80.0.0 255.255.255.0
push "route 192.168.1.0 255.255.255.0"
#push "route-gateway 10.80.0.1"
keepalive 10 120
comp-lzo
persist-key
persist-tun
#duplicate-cn
status /etc/openvpn/server/onlineusers.log 5
verb 3
mute 20
log /var/log/openvpn.log

kliens:

remote x.x.x.x 1194
client
dev tun
proto udp
resolv-retry infinite
nobind
persist-key
persist-tun
ca /etc/openvpn/ca.crt
cert /etc/openvpn/sztupi.crt
key /etc/openvpn/sztupi.key
dh /etc/openvpn/dh2048.pem
comp-lzo
verb 1
mute 5
#auth-user-pass
ns-cert-type server
#conf vége

Sziasztok,

elnezest nem voltam elerheto. Szal Mukodik.
S ami tortent :

A firewall scriptet ujra irtam , de szorol szora ugyan azt mint az elozoben volt es ime mukodik.
Lehetett benne vmi olyan lathatalan karakter ami elrontotta? Nem tudom passz.
Amikor osszehasonlitottam a ket scriptet nem mutatott a diffuse semmi kulombseget, ezert csak tippelni tudok.
Mondjuk ez a legbosszantobb mert nem derul ki a hiba.

A segitsegeteket koszonom
Sztupi

Ez teszteles alatt levo rendszeren mindig rossz otlet, eles rendszeren pedig max burst-ot raksz ra, de semmikepp se tiltsd az ICMP csomagokat, mert magadat szurod tokon amikor tesztelni kell. Volt tiltott ICMP-s rendszerrel dolgom, szoval tudom, mit beszelek. Sok ora headbangtol kimeled meg magadat.
--


()=() Ki oda vagyik,
('Y') hol szall a galamb
C . C elszalasztja a
()_() kincset itt alant.

Azt megpróbáltad már, hogy UDP-ről TCP-re átrakni /avagy fordítva/? Lehet a szolgáltatónál változott valami a gatewaynél.