1

Temat: Problem z routingiem openvpn na openwrt

Witam.

Poległem na ustawianiu routingu w sieci domowej, chciałem się was zapytać gdzie robię błąd bo już brak mi sił. Założenie jest takie żeby obie sieci widziały się w pełni. OpenVPN jest skonfigurowany w trybie routera w sumie most byłby łatwiejszy no ale takie było założenie... W jednej sieci ustawiona jest podsieć 192.168.0.0/24 a w drugiej 192.168.1.0/24. Tunel ma adresację 10.7.0.0/24.


W sieci 192.168.1.0/24 gdzie "końcówka tunelu" ma adres 10.7.0.6 ustawiłem routing: ip r a 192.168.0.0/24 via 10.7.0.6 i pinguje się do każdego komputera w sieci 192.168.0.0/24.

Problem pojawia się w drugą stronę. (od strony serwera VPN czyli OpenWRT). Analogicznie dodałem: route add -net 192.168.1.0/24 gw 10.7.0.1 no i nic... Jak próbuje ping 10.7.0.6 to jest ok ale ping 192.168.1.1 nie znajduje hosta. Z końcówek przy pingu 10.7.0.1 jest ok a 10.7.0.6 nie przechodzi.

Końcówki próbowałem ustawić aby przechodziły przez adres routera (openwrt) jak i adres tunelu.

routing na Serwerze VPN

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.20.0       *               255.255.255.0   U     0      0        0 br-lan
192.168.1.0     *               255.255.255.0   U     0      0        0 tun0
192.168.0.0     *               255.255.255.0   U     0      0        0 eth0.2
10.7.0.0        *               255.255.255.0   U     0      0        0 tun0
default         192.168.0.1     0.0.0.0         UG    0      0        0 eth0.2

Próbowałem też

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.20.0       *                255.255.255.0   U     0      0        0 br-lan
192.168.1.0     10.7.0.1     255.255.255.0   U     0      0        0 tun0
192.168.0.0     *              255.255.255.0   U     0      0        0 eth0.2
10.7.0.0        *                255.255.255.0   U     0      0        0 tun0
default         192.168.0.1     0.0.0.0         UG    0      0        0 eth0.2

konfiguracja openvpn

root@OpenWrt:~$ cat /etc/openvpn/tunel.conf
dev tun
mode server
proto udp
port 1973
ca /etc/openvpn/certs/cacert.pem
cert /etc/openvpn/certs/servercert.pem
key /etc/openvpn/certs/serverkey.pem_bezhasla
dh /etc/openvpn/certs/dh1024.pem
server 10.7.0.0 255.255.255.0
status /var/log/openvpn2.log
keepalive 10 120
comp-lzo
cipher AES-128-CBC
log /tmp/log/openvpn.log
verb 6
ifconfig-pool-persist ipp.txt

2

Odp: Problem z routingiem openvpn na openwrt

Firewalla pokaż.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

3

Odp: Problem z routingiem openvpn na openwrt

root@OpenWrt:~$ iptables -L INPUT
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere
syn_flood  tcp  --  anywhere             anywhere            tcp flags:FIN,SYN,RST,ACK/SYN
input_rule  all  --  anywhere             anywhere
input      all  --  anywhere             anywhere
root@OpenWrt:~$ iptables -L OUTPUT
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere
output_rule  all  --  anywhere             anywhere
output     all  --  anywhere             anywhere
root@OpenWrt:~$

4

Odp: Problem z routingiem openvpn na openwrt

Ehh.

/etc/config/firewall i /etc/firewall.user

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

5 (edytowany przez Doom 2012-03-21 22:59:28)

Odp: Problem z routingiem openvpn na openwrt

root@OpenWrt:~$ cat /etc/config/firewall
config 'rule'
        option '_name' 'openvpn'
        option 'src' 'wan'
        option 'target' 'ACCEPT'
        option 'proto' 'udp'
        option 'dest_port' '1973'
        option 'src_port' '1973'

config 'rule'
        option 'name' 'Allow-DHCP-Renew'
        option 'src' 'wan'
        option 'proto' 'udp'
        option 'dest_port' '68'
        option 'target' 'ACCEPT'
        option 'family' 'ipv4'

config 'rule'
        option 'name' 'Allow-Ping'
        option 'src' 'wan'
        option 'proto' 'icmp'
        option 'icmp_type' 'echo-request'
        option 'family' 'ipv4'
        option 'target' 'ACCEPT'

config 'rule'
        option 'name' 'Allow-DHCPv6'
        option 'src' 'wan'
        option 'proto' 'udp'
        option 'src_ip' 'fe80::/10'
        option 'src_port' '547'
        option 'dest_ip' 'fe80::/10'
        option 'dest_port' '546'
        option 'family' 'ipv6'
        option 'target' 'ACCEPT'

config 'rule'
        option 'name' 'Allow-ICMPv6-Input'
        option 'src' 'wan'
        option 'proto' 'icmp'
        list 'icmp_type' 'echo-request'
        list 'icmp_type' 'destination-unreachable'
        list 'icmp_type' 'packet-too-big'
        list 'icmp_type' 'time-exceeded'
        list 'icmp_type' 'bad-header'
        list 'icmp_type' 'unknown-header-type'
        list 'icmp_type' 'router-solicitation'
        list 'icmp_type' 'neighbour-solicitation'
        option 'limit' '1000/sec'
        option 'family' 'ipv6'
        option 'target' 'ACCEPT'

config 'rule'
        option 'name' 'Allow-ICMPv6-Forward'
        option 'src' 'wan'
        option 'dest' '*'
        option 'proto' 'icmp'
        list 'icmp_type' 'echo-request'
        list 'icmp_type' 'destination-unreachable'
        list 'icmp_type' 'packet-too-big'
        list 'icmp_type' 'time-exceeded'
        list 'icmp_type' 'bad-header'
        list 'icmp_type' 'unknown-header-type'
        option 'limit' '1000/sec'
        option 'family' 'ipv6'
        option 'target' 'ACCEPT'

config 'defaults'
        option 'syn_flood' '1'
        option 'input' 'ACCEPT'
        option 'output' 'ACCEPT'
        option 'forward' 'REJECT'
        option 'drop_invalid' '0'

config 'zone'
        option 'name' 'lan'
        option 'network' 'lan'
        option 'input' 'ACCEPT'
        option 'output' 'ACCEPT'
        option 'forward' 'REJECT'

config 'zone'
        option 'name' 'wan'
        option 'network' 'wan'
        option 'input' 'REJECT'
        option 'output' 'ACCEPT'
        option 'forward' 'REJECT'
        option 'masq' '1'
        option 'mtu_fix' '1'

config 'forwarding'
        option 'src' 'lan'
        option 'dest' 'wan'

config 'include'
        option 'path' '/etc/firewall.user'


root@OpenWrt:~$ cat /etc/firewall.user


iptables -I OUTPUT -o tun+ -j ACCEPT
iptables -I INPUT -i tun+ -j ACCEPT
iptables -I FORWARD -o tun+ -j ACCEPT
iptables -I FORWARD -i tun+ -j ACCEPT


Takie pytanie przy okazji czy sekcja:

config 'forwarding'
        option 'src' 'lan'
        option 'dest' 'wan'

Nie powinna być też w drugą stronę:
src wan i desc lan ?

6

Odp: Problem z routingiem openvpn na openwrt

Ten vpn do której sekcji w końcu należy?

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

7

Odp: Problem z routingiem openvpn na openwrt

to znaczy  ?

8

Odp: Problem z routingiem openvpn na openwrt

To co pokazałeś to zwykły wan/lan. Jeżeli zrobiłeś vpn, to gdzie go w firewallu wrzuciłeś?

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

9 (edytowany przez Doom 2012-03-24 10:19:20)

Odp: Problem z routingiem openvpn na openwrt

Czy coś takiego wystarczy: 

config 'rule'
        option 'name' 'tunel'
        option 'src' 'tun'
        option 'proto' 'tcpudp'
        option 'dest' 'lan'
        option 'target' 'ACCEPT'

config 'redirect'
        option 'src' 'wan'
        option 'src_dport' '80'       
        option 'dest_ip' '10.7.0.6'
        option 'proto' 'tcp'
       
config 'zone'
        option 'name' 'tun'
        option 'network' 'tun'
        option 'input' 'ACCEPT'
        option 'output' 'ACCEPT'
        option 'forward' 'ACCEPT'

config 'forwarding'
        option 'src' 'tun'
        option 'dest' 'lan'

10.7.0.6 jest serwerem www