The VPN client just should have a connection to my server with ip address 192.144.12.42 and all another internet requests shouldn't go through the VPN connection. So only the IP address 192.144.12.42 can be called. So I install a VPN server with the IPTables rules:
iptables -t nat -A POSTROUTING -s 10.100.170.0/24 -d 192.144.12.42 -j MASQUERADE
It means, the VPN IP address 10.100.170.0/24 just can call 192.144.12.42. So the other requests like google.de doesn't work anymore after the VPN connection of course. Thats why I want make a VPN splitting. So I changed my VPN client configuration:
[Interface]
PrivateKey = ???????????=
Address = 10.100.170.9/24,???:???:???:???::4/64
DNS = 9.9.9.9, 149.112.112.112
[Peer]
PublicKey = ?????????=
PresharedKey = U????????=0=
Endpoint = im.secret.domain:51820
AllowedIPs = 192.144.12.42/32
But only my IP address 192.144.12.42 is available but the other pages not (like google.com). Do you know why?
Summary:
Requirement: Add: The PC is in a different network no 192.144.12, the PC has internet via LTE for example or this is in a hotel network. I want the user of the PC is able to connect to the Wireguard VPN server (Raspberry Pi2), he enter the address 192.144.12.42 into the browser and the Http server from the Raspberry PI 2 response (On the Raspberry Pi2 the VPN Wireguard server and an HTTP server are installed). If the user of PC enters google.com in the browser, then the VPN connection should not be used (i.e. a split connection). If the user enters 192.144.12.23 from the PC in the browser, then nothing should shown (so the Raspberry Pi1 should not response).
What was successfully implemented: The PC user can connect to the Wireguard VPN server. If the user of the PC enters 192.144.12.42 in the browser, then the HTTP server is reachable (on the Raspberry Pi2), if the user of the PC enters 192.144.12.23 in the browser, then nothing will shown (So Raspberry PI1 doesn't response).
Which does not work: If the user of the PC wants to call up google.com in the browser, then nothing appears because the call is made via the VPN connection and he cannot resolve the domain google.com . If I disconnect the VPN connection, the user via PC can open the page google.com