Mac OS VPN Routing
By Mac’s means, this can be done by creating a VPN connection and 2 options:
1. check the box “Send all traffic through VPN connection”
2. statically register statically route add -net 192.168.10.0/24 192.168.44.1, where 192.168.10.0/24 is the network in which computers are at work, 192.168.44.1 VPN gateway to which I connect.
So, after each connection, you need to do a second manipulation, since the general access to the Internet is limited and the speed is not great. Or the task is to go to sites (for example, youtube) through a faster VPN channel ...
So I solved the problem as follows:
created a script:
touch /etc/ppp/ip-upgave it the right to execute:
chmod +x /etc/ppp/ip-upcreated a file for logs:
touch /tmp/ppp.logContent of the script: Thus, after connecting to the network, the route is added, and there is no need to add it manually, as well, when disconnected from the VPN, it is deleted by itself. If you need to add a DNS server, you can add text between then and fi: Instead of 4.2.2.1, specify your main DNS and the second working record. But at the same time, after disconnecting, we need to return the previous DNS config to the place, for this we create: Before starting work, we backup: and add to the script / etc / ppp / ip-down: Actually everything. Each time the VPN connection is established, the route is prescribed, you work as long as necessary, it is deleted after disconnection, and you will not have any snags with DNS.
#!/bin/sh
VPNWORK="192.168.44.1"; #обьявляем переменную (например по названию VPN подключения)
if [ $IPREMOTE = $VPNWORK ] #проверяем, если совпадает добавляем маршрут
then
/sbin/route -n add -net 192.168.10.0/24 $IPREMOTE > /tmp/ppp.log 2>&1
fi
echo "nameserver 4.2.2.1" > /etc/resolv.conftouch /etc/ppp/ip-down && chmod +x /etc/ppp/ip-downcp /etc/resolv.conf /etc/resolv.conf_original#!/bin/sh
cat /etc/resolv.conf_original > /etc/resolv.conf