Статические маршруты в macos при поднятии VPN

По-умолчанию, при поднятии VPN соединения, Mac OS X пропишет только один статический маршрут, соответствующий создаваемому туннелю. Но бывают ситуации когда необходимо прописать несколько маршрутов для подсетей или хостов. Решить данный вопрос в GUI Mac OS X невозможно. Но возможно через консоль(терминал).

Итак, открываем терминал. Для решения данной задачи создадим файл /etc/ppp/ip-up, и сделаем его исполняемым:

sudo touch /etc/ppp/ip-up
sudo chmod a+x /etc/ppp/ip-up

Открываем созданный файл для редактирования

sudo vim /etc/ppp/ip-up

и пропишем в нем:

#!/bin/sh
ifname=$1        # имя интерфейса pppd (например, ppp3)
ttyname=$2       # имя tty устройства
speed=$3         # скорость tty устройства
localip=$4       # локальный ip адрес
remoteip=$5      # удаленный ip адрес
ipparam=$6       # текущий ip адрес перед установлением VPN соединения

case "$remoteip" in
#IP 1 филиала
    192.168.20.1)
	/sbin/route add -net 192.173.0.0/24 -interface $ifname
        ;;
#IP 2 филиала
    192.168.1.239)
	/sbin/route add -net 192.168.1.0/24 -interface $ifname
        ;;
esac
exit 0;

В данном примере 192.168.20.1 и 192.168.1.239  это ip-адреса VPN-серверов после установления соединения. 192.173.0.0/24 и 192.168.1.0 подсети которые нам необходимо прописать в статичных маршрутах. IP-адрес сервера можно посмотреть после установления VPN соединения командой ifconfig и найти интерфейс ppp0.

ppp0: flags=8051<up,pointopoint,running,multicast> mtu 1448
 inet 192.168.20.57 --> 172.24.48.116 netmask 0xffffff00

Аналогично можно сделать скрипт для удаления маршрутов /etc/ppp/ip-down, который будет вызываться при остановке VPN туннеля:

/sbin/route delete -net 192.0.2.0/24 -interface $ifname
/sbin/route delete -host 192.168.12.54 -interface $ifname
Рекомендуем почитать
PPTP VPN сервер в 3 конфигурационных файлах

Тема конечно избита. Но я все равно расскажу как установить pptp демон =) Команда для установки сервера будет варьироваться в Читать дальше...

NEOPbx / Elastix VPN server module

Customer VID Ltd. Project NEOPbx State Ready Description Develop module for VPN server managment. Demo VPN server module

Как узнать ip адрес интерфейса и вывести только его

Маленький пример о том как использовать ifconfig, cut и awk чтобы вывести только ip адрес. Вывод команды ifconfig будет таким: Читать дальше...

Поделиться

61 комментарий к “Статические маршруты в macos при поднятии VPN

  1. I just want to mention I’m newbie to weblog and seriously loved you’re blog site. Probably I’m planning to bookmark your blog post . You surely have outstanding well written articles. With thanks for sharing your web-site.

  2. The next time I review a blog site, I hope that it doesn’t disappoint me as high as this. I suggest, I understand it was my option to check out, however I actually thought youd have something fascinating to state. All I listen to is a number of yawping about something that you might take care of if you werent too active trying to find attention.

  3. I am really loving the theme/design of your weblog. Do you ever run into any web browser compatibility problems? A handful of my blog audience have complained about my site not working correctly in Explorer but looks great in Opera. Do you have any tips to help fix this issue?

  4. I uncovered your blog website on google and inspect a few of your very early messages. Continue to keep up the very good operate. I simply extra up your RSS feed to my MSN Information Reader. Looking for ahead to reading more from you later on!?

  5. There are a couple of fascinating points with time in the following paragraphs but I do not know if all of them center to heart. There’s some validity but I most certainly will take hold opinion until I check into it further. Very good post , thanks and then we want a lot more! Included with FeedBurner at the same time

  6. Hi there would you mind sharing which blog platform you’re using?
    I’m looking to start my own blog soon but I’m having a tough time deciding between BlogEngine/Wordpress/B2evolution and Drupal.

    The reason I ask is because your design and style seems
    different then most blogs and I’m looking for something unique.
    P.S Apologies for being off-topic but I had to ask!

  7. After looking at a number of the blog posts on your web page, I seriously appreciate your way of writing a blog. I bookmarked it to my bookmark site list and will be checking back soon. Take a look at my web site as well and tell me what you think.

  8. A remarkable share, I simply offered this onto a colleague who was doing a little evaluation on this. As well as he actually acquired me morning meal since I discovered it for him. smile. So let me reword that: Thnx for the reward! However yeah Thnkx for investing the time to discuss this, I feel highly concerning it and also like finding out more on this subject. Preferably, as you end up being experience, would certainly you mind updating your blog with even more details? It is highly useful for me. Big thumb up for this post!

  9. Fantastic goods from you, man. I’ve understand your stuff previous to and you are just too excellent.
    I really like what you have acquired here, really like what
    you are stating and the way in which you say it.

    You make it enjoyable and you still care for to keep it smart.
    I can not wait to read much more from you. This is actually a wonderful website.

  10. There are certainly a lot of details like that to consider. That is an excellent indicate raise. I provide the ideas over as basic inspiration but plainly there are concerns like the one you bring up where one of the most important point will be working in honest good faith. I don?t know if ideal practices have arised around points like that, but I am sure that your job is plainly identified as a level playing field. Both young boys and women feel the effect of simply a moment?s enjoyment, for the rest of their lives.

  11. Fantastic goods from you, man. I have understand your stuff previous to and you
    are just extremely wonderful. I really like what you have acquired here, certainly like what you’re saying and the way in which you say it.
    You make it enjoyable and you still take care of to keep it smart.
    I can not wait to read far more from you. This is actually a wonderful site.

  12. Environment Awareness is the notice of the significance and fragility of the environment. It helps us realize the fragility of the environment by making us understand the things that we can do and contribute to the preservation of the environment. Environmental consciousness is a straightforward method to be an lively environmentalist and help contribute in making a shiny future for future generations. It is also important for us to know the things that are contributing in the direction of the destruction of the environment and what could be done to stop them from taking place.

  13. There are some fascinating moments in this short article but I don?t recognize if I see all of them facility to heart. There is some legitimacy but I will take hold point of view till I explore it additionally. Great write-up, many thanks and also we desire a lot more! Included in FeedBurner too

  14. Have you ever thought about including a little bit more than just your articles?
    I mean, what you say is valuable and all. But imagine if you added some great
    images or videos to give your posts more, “pop”! Your content is excellent but with pics
    and videos, this blog could certainly be one of
    the very best in its field. Excellent blog! adreamoftrains best web hosting 2020

  15. The next time I check out a blog site, I hope that it doesn’t disappoint me as much as this set. I imply, I know it was my choice to check out, yet I in fact believed youd have something fascinating to claim. All I hear is a bunch of whimpering about something that you might repair if you werent too hectic seeking focus.

  16. A fascinating discussion deserves comment. I believe that you must write more on this topic, it might not be a taboo topic however generally individuals are inadequate to speak on such subjects. To the next. Cheers

  17. There are certainly a great deal of details like that to think about. That is an excellent point to bring up. I offer the ideas over as basic inspiration but clearly there are questions like the one you bring up where the most vital thing will certainly be operating in honest good faith. I don?t know if ideal methods have actually arised around things like that, however I make certain that your job is clearly determined as a fair game. Both children as well as women really feel the impact of simply a moment?s pleasure, for the remainder of their lives.

  18. Thanks for any other excellent post. Where else may anybody get that type of information in such a perfect approach of writing? I’ve a presentation next week, and I’m at the search for such information.

  19. The following time I review a blog, I wish that it doesn’t dissatisfy me as long as this set. I suggest, I know it was my choice to check out, but I in fact thought youd have something intriguing to state. All I listen to is a bunch of whining regarding something that you might take care of if you werent also active looking for attention.

  20. Hello there, just became aware of your blog through Google,
    and found that it is truly informative. I’m gonna watch out for brussels.
    I will be grateful if you continue this in future.
    Lots of people will be benefited from your writing. Cheers!

  21. I am extremely impressed with your writing skills and also with the layout on your blog.
    Is this a paid theme or did you modify it yourself?
    Anyway keep up the nice quality writing, it’s rare to see a
    nice blog like this one nowadays.

  22. With havin so much content and articles do you ever run into any
    issues of plagorism or copyright violation? My blog has a lot of exclusive content I’ve either authored myself or outsourced
    but it appears a lot of it is popping it up all over the internet without my permission. Do you know any
    ways to help reduce content from being stolen? I’d definitely
    appreciate it.

Оставить ответ

Ваш адрес email не будет опубликован. Обязательные поля помечены *