Openvpn Subnet Routing

Einrichten des lokalen Netzes, Verbindung zu anderen Computern und Diensten.
Antworten
honigmaus
Beiträge: 23
Registriert: 27.11.2003 15:06:31
Lizenz eigener Beiträge: MIT Lizenz

Openvpn Subnet Routing

Beitrag von honigmaus » 08.07.2023 14:05:58

Servus,
ich hab eine VM mit einem Openvpn Server und Debian Router mit Openvpn an mehreren Lokationen.

Nun sehe ich am Server (88.1):

Code: Alles auswählen

root@vpn:/etc/openvpn# ip r
default via PUBLICIP dev eth0 
PUBLICIP dev eth0 scope link 
192.168.2.0/24 via 192.168.88.2 dev tun0 # 88.2 ist ein Router mit dem Subnetz 192.168.2.0/24 dahinter, ok
192.168.88.0/24 dev tun0 proto kernel scope link src 192.168.88.1 # Das Openvpn Netz, ok
192.168.178.0/24 via 192.168.88.2 dev tun0 # 192.168.178.0/24 liegt nicht hinter 88.2, es liegt hinter 88.12!
Falls ich nix übersehen hab ist da nix in den configs:

Code: Alles auswählen

root@vpn:/etc/openvpn# grep -r 178 *
client/client88.12:iroute 192.168.178.0 255.255.255.0
openvpn-status.log:client88.2,178.112.33.1:63089,6087,10502,2023-07-08 13:39:37
openvpn-status.log:192.168.178.0/24,client88.12,185.128.245.218:60065,2023-07-08 13:39:37
openvpn-status.log:192.168.178.1C,client88.12,185.128.245.218:60065,2023-07-08 13:51:15
openvpn-status.log:192.168.2.0/24,client88.2,178.112.33.1:63089,2023-07-08 13:39:37
openvpn-status.log:192.168.88.2,client88.2,178.112.33.1:63089,2023-07-08 13:39:37
server.conf:push "route 192.168.178.0 255.255.255.0" # Lokation hinter 88.12
server.conf:route 192.168.178.0 255.255.255.0 # Lokation hinter 88.12
Die client.conf von 88.2:

Code: Alles auswählen

# set a static IP
ifconfig-push 192.168.88.2 255.255.255.0
# route into
iroute 192.168.2.0 255.255.255.0
Die client.conf von 88.12:

Code: Alles auswählen

# set a static IP
ifconfig-push 192.168.88.12 255.255.255.0
# route into
iroute 192.168.178.0 255.255.255.0
server.conf:

Code: Alles auswählen

port 1194
proto udp
dev tun
topology subnet
push "topology subnet"
server 192.168.88.0 255.255.255.0

# advertises to the VPN clients as being accessible through the VPN
#push "route 192.168.88.0 255.255.255.0"
push "route 192.168.2.0 255.255.255.0" # Location behind 88.2
push "route 192.168.178.0 255.255.255.0" # Location behind 88.12

# routing
client-to-client
client-config-dir /etc/openvpn/client

# controls the routing from the kernel to the OpenVPN server (via the TUN interface) 
#route 192.168.88.0 255.255.255.0 # VPN Network
route 192.168.2.0 255.255.255.0 # Location behind 88.2
route 192.168.178.0 255.255.255.0 # Location behind 88.12

ca /etc/openvpn/easy-rsa/pki/ca.crt
cert /etc/openvpn/easy-rsa/pki/issued/vpn.domain.at.crt
key /etc/openvpn/easy-rsa/pki/private/vpn.domain.at.key
dh /etc/openvpn/easy-rsa/pki/dh.pem

user nobody
group nogroup

ifconfig-pool-persist ipp.txt

data-ciphers-fallback AES-256-CBC
keepalive 10 120
allow-compression yes
comp-lzo
persist-key
persist-tun
status openvpn-status.log
Warum glaubt der Server dass er 178.0/24 hinter 88.2 finden kann?
lg, honigmaus

mat6937
Beiträge: 2953
Registriert: 09.12.2014 10:44:00

Re: Openvpn Subnet Routing

Beitrag von mat6937 » 08.07.2023 15:01:18

honigmaus hat geschrieben: ↑ zum Beitrag ↑
08.07.2023 14:05:58

Code: Alles auswählen

route 192.168.2.0 255.255.255.0 # Location behind 88.2
route 192.168.178.0 255.255.255.0 # Location behind 88.12
Warum glaubt der Server dass er 178.0/24 hinter 88.2 finden kann?
Wie ist die Ausgabe von:

Code: Alles auswählen

ip r g 192.168.178.1
?

honigmaus
Beiträge: 23
Registriert: 27.11.2003 15:06:31
Lizenz eigener Beiträge: MIT Lizenz

Re: Openvpn Subnet Routing

Beitrag von honigmaus » 08.07.2023 15:04:11

Code: Alles auswählen

vpn:~$ ip r g 192.168.178.1
192.168.178.1 via 192.168.88.2 dev tun0 src 192.168.88.1 uid 1001 
    cache 
lg, honigmaus

mat6937
Beiträge: 2953
Registriert: 09.12.2014 10:44:00

Re: Openvpn Subnet Routing

Beitrag von mat6937 » 08.07.2023 15:19:08

honigmaus hat geschrieben: ↑ zum Beitrag ↑
08.07.2023 15:04:11

Code: Alles auswählen

vpn:~$ ip r g 192.168.178.1
192.168.178.1 via 192.168.88.2 dev tun0 src 192.168.88.1 uid 1001 
    cache 
Das gateway ist 192.168.88.2 und die source-IP ist 192.168.88.1.
Kannst Du einen Ping mit der source-IP 192.168.88.12 machen:

Code: Alles auswählen

ping -c 3 -I 192.168.88.12 192.168.178.1
?
Wie ist die Ausgabe von:

Code: Alles auswählen

ip a
?

honigmaus
Beiträge: 23
Registriert: 27.11.2003 15:06:31
Lizenz eigener Beiträge: MIT Lizenz

Re: Openvpn Subnet Routing

Beitrag von honigmaus » 08.07.2023 17:04:54

Danke für deine Hilfe! - Sorry dass ich nicht dauernd da bin ... Gäste ...

Code: Alles auswählen

client88.12:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host proto kernel_lo 
       valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:e2:69:57:03:a7 brd ff:ff:ff:ff:ff:ff
3: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1492 qdisc mq state UP group default qlen 1000
    link/ether 00:e2:69:57:03:a8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.178.1/24 brd 192.168.178.255 scope global enp2s0
       valid_lft forever preferred_lft forever
4 ... 9
10: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 500
    link/none 
    inet 192.168.88.12/24 scope global tun0
       valid_lft forever preferred_lft forever

Code: Alles auswählen

client88.12:~# ping -c 3 -I 192.168.88.12 192.168.178.1
PING 192.168.178.1 (192.168.178.1) from 192.168.88.12 : 56(84) bytes of data.
64 bytes from 192.168.178.1: icmp_seq=1 ttl=64 time=0.173 ms
64 bytes from 192.168.178.1: icmp_seq=2 ttl=64 time=0.107 ms
64 bytes from 192.168.178.1: icmp_seq=3 ttl=64 time=0.172 ms
lg, honigmaus

mat6937
Beiträge: 2953
Registriert: 09.12.2014 10:44:00

Re: Openvpn Subnet Routing

Beitrag von mat6937 » 08.07.2023 17:22:45

honigmaus hat geschrieben: ↑ zum Beitrag ↑
08.07.2023 17:04:54

Code: Alles auswählen

3: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1492 qdisc mq state UP group default qlen 1000
    link/ether 00:e2:69:57:03:a8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.178.1/24 brd 192.168.178.255 scope global enp2s0
       valid_lft forever preferred_lft forever
4 ... 9
10: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 500
    link/none 
    inet 192.168.88.12/24 scope global tun0
       valid_lft forever preferred_lft forever

Code: Alles auswählen

client88.12:~# ping -c 3 -I 192.168.88.12 192.168.178.1
PING 192.168.178.1 (192.168.178.1) from 192.168.88.12 : 56(84) bytes of data.
Dann mach den Ping auf eine anderen IP-Adresse aus dem .178.0/24er-Subnetz. Evtl. auch ein traceroute:

Code: Alles auswählen

mtr -4nr -c 1 192.168.178.xxx   # .xxx > .1

honigmaus
Beiträge: 23
Registriert: 27.11.2003 15:06:31
Lizenz eigener Beiträge: MIT Lizenz

Re: Openvpn Subnet Routing

Beitrag von honigmaus » 08.07.2023 17:30:08

oha!

Code: Alles auswählen

client88.12:~# ping -c 3 -I 192.168.88.12 192.168.178.2
PING 192.168.178.2 (192.168.178.2) from 192.168.88.12 : 56(84) bytes of data.
^C
--- 192.168.178.2 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2032ms

Code: Alles auswählen

client88.12:~# ping -c 3 -I 192.168.178.1 192.168.178.2
PING 192.168.178.2 (192.168.178.2) from 192.168.178.1 : 56(84) bytes of data.
64 bytes from 192.168.178.2: icmp_seq=1 ttl=64 time=5.52 ms
edit: ip r dazu:

Code: Alles auswählen

client88.12:~# ip r
default dev ftth scope link 
PUBLICIP dev ftth proto kernel scope link src PUBLICIP
192.168.0.0/24 via 192.168.88.1 dev tun0 
192.168.2.0/24 via 192.168.88.1 dev tun0 
192.168.88.0/24 dev tun0 proto kernel scope link src 192.168.88.12 
192.168.178.0/24 dev enp2s0 proto kernel scope link src 192.168.178.1 
/me geht jetzt mal nachdenken ...
lg, honigmaus

Antworten