openvpn restart
В скрипте автоматического перехода на резервный канал использую:
/etc/init.d/openvpn restart
После этого openvpn не поднимается. Попробовал прописать /etc/init.d/openvpn restart в crontab -e под рутом. Туннель упал, но не поднялся. Использую tun
adxfighter
16.10.13 09:56:54 MSK
Initialization Sequence Completed ovpn-client[19613]: Replay-window backtrack occurred [1] ovpn-client[19613]: event_wait : Interrupted system call (code=4)
adxfighter
( 16.10.13 10:10:41 MSK ) автор топика
а указать путь к конфигу?
сам туннель у тебя в принципе настроен?
flant ★★★
( 16.10.13 10:15:57 MSK )
Ответ на: комментарий от flant 16.10.13 10:15:57 MSK
Да, туннель годами работает. И рестарт из консоли работает. И рестарт из скрипта работает. А вот с cronом какая-то беда. Конфиг он видит.
Oct 16 09:51:01 GWVolgograd ovpn-client[19613]: event_wait : Interrupted system call (code=4) Oct 16 09:51:01 GWVolgograd ovpn-client[19613]: TCP/UDP: Closing socket Oct 16 09:51:01 GWVolgograd ovpn-client[19613]: /sbin/route del -net 10.55.0.0 netmask 255.255.0.0 Oct 16 09:51:01 GWVolgograd ovpn-client[19613]: /sbin/route del -net 10.16.0.0 netmask 255.240.0.0 Oct 16 09:51:01 GWVolgograd ovpn-client[19613]: /sbin/route del -net 10.8.0.0 netmask 255.248.0.0 Oct 16 09:51:01 GWVolgograd ovpn-client[19613]: /sbin/route del -net 10.6.0.0 netmask 255.254.0.0 Oct 16 09:51:01 GWVolgograd ovpn-client[19613]: /sbin/route del -net 10.5.0.0 netmask 255.255.0.0 Oct 16 09:51:01 GWVolgograd ovpn-client[19613]: /sbin/route del -net 10.0.0.0 netmask 255.252.0.0 Oct 16 09:51:01 GWVolgograd ovpn-client[19613]: /sbin/route del -net 192.168.2.0 netmask 255.255.255.0 Oct 16 09:51:01 GWVolgograd ovpn-client[19613]: /sbin/route del -net 192.168.1.0 netmask 255.255.255.0 Oct 16 09:51:01 GWVolgograd ovpn-client[19613]: /sbin/route del -net 192.168.100.0 netmask 255.255.252.0 Oct 16 09:51:01 GWVolgograd ovpn-client[19613]: Closing TUN/TAP interface Oct 16 09:51:01 GWVolgograd ovpn-client[19613]: /sbin/ifconfig tun0 0.0.0.0
Как запустить OpenVPN, при перезагрузке
Какая-то странная причина, я не могу заставить мой сервер OpenVPN запускаться во время загрузки, используя systemd на сервере Ubuntu Linux 16.04 LTS. Я пробовал несколько настроек, но не получилось.
Вот мой файл /lib/systemd/system/openvpn.service:
# cat /lib/systemd/system/openvpn.service
# This service is actually a systemd target, # but we are using a service since targets cannot be reloaded. [Unit] Description=OpenVPN service After=network.target [Service] Type=oneshot RemainAfterExit=yes ExecStart=/bin/true ExecReload=/bin/true WorkingDirectory=/etc/openvpn [Install] WantedBy=multi-user.target
Я хотел запустить сервисы после того, как сеть будут запущена, чтобы OpenVPN мог привязать определенный IP-адрес и порт. После = network.target говорит ждать, пока nework «запуститься».
Мое решение проблемы
Я, наконец, сдался и просто написал задание cron, которое начнется после каждой перезагрузки системы:
@reboot sleep 100;/etc/init.d/openvpn restart;/etc/init.d/ssh restart;/etc/init.d/squid reload
Команда @reboot принудительно запускает задание один раз при запуске. В этом случае перезапустится сервер openvpn и sshd:
$ ss -tulpn
$ netstat -tulpn
tcp 0 0 10.8.0.1:80 0.0.0.0:* LISTEN 1549/lighttpd tcp 0 0 0.0.0.0:53 0.0.0.0:* LISTEN 1524/dnsmasq tcp 0 0 10.8.0.1:22 0.0.0.0:* LISTEN 1756/sshd tcp 0 0 10.8.0.1:3128 0.0.0.0:* LISTEN 1675/(squid-1) tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 1732/openvpn
Должен быть способ запуска сервисов (OpenVPN) после выхода из сети. Однако я не смог понять. Если кто-нибудь знает, как решить эту проблему без использования cron, дайте мне знать в разделе комментариев ниже.
Похожие статьи:
- Как перезагрузить службу php7.0-fpm / php5.0-fpm
- Ошибка apache: Too many open files
- Перезапуск агентов управления на сервере Vmware esx
- Proxmox и OpenVPN
OpenVPN Support Forum
Forum rules
Please use the [oconf] BB tag for openvpn Configurations. See viewtopic.php?f=30&t=21589 for an example.
5 posts • Page 1 of 1
ScKaSx444 OpenVpn Newbie Posts: 6 Joined: Mon May 16, 2011 5:05 am
Restarting OpenVPN Server
Post by ScKaSx444 » Tue Jun 07, 2011 11:46 pm
I am trying to debug my configuration files for a client-server setup, where (client=my laptop, Windows 7) and (server=NAS hard drive, Linux). When I make changes to the server configuration I would like to restart the OpenVPN server. To do this is it okay to just run from the command line:
openvpn new_config.config
It is not necessary to power cycle the hard drive, correct? I appreciate the help.
Bebop Forum Team Posts: 301 Joined: Wed Dec 15, 2010 9:24 pm
Re: Restarting OpenVPN Server
Post by Bebop » Wed Jun 08, 2011 7:37 am
Power cycle is definitely not necessary. The exact method you use will depend on your OS, and whether you start as a service or not.
service openvpn restart
Debian service:
/etc/init.d/openvpn restart
In your case:
openvpn new_config.config
are you stopping the old instance first? (ctrl+c)
If yes, then you are doing all that is required. Nothing further required.
The cure for boredom is curiosity
ScKaSx444 OpenVpn Newbie Posts: 6 Joined: Mon May 16, 2011 5:05 am
Re: Restarting OpenVPN Server
Post by ScKaSx444 » Thu Jun 16, 2011 5:08 pm
Thanks for the response, great name btw as it was also a great show.
I read about stopping the service with ctrl-c but I can’t tell if that does anything when I do that. Can I check ‘jobs’ or ‘processes’ in linux to see if it is/isn’t running in the background? Does linux have a restart function like with Debian or Centos?
janjust Forum Team Posts: 2703 Joined: Fri Aug 20, 2010 2:57 pm Location: Amsterdam Contact:
Re: Restarting OpenVPN Server
Post by janjust » Fri Jun 17, 2011 7:37 am
this depends on your linux distro; the centos+debian scripts are wrappers around the openvpn command itself; if openvpn is launched from the command line without using ‘deamon’ then a CTRL+C is sufficient; if openvpn is daemonized you can find the processes using
ps -elf | grep openvpn
a quick&dirty way to kill all openvpn processes is
killall openvpn
but again, this depends a bit on the linux distro used on the NAS box.
david01 OpenVpn Newbie Posts: 1 Joined: Thu Jun 03, 2021 2:57 pm
Re: Restarting OpenVPN Server
Post by david01 » Thu Jun 03, 2021 3:00 pm
to restart the service
if you on Redhat or CentOS
[root@localhost ~]# systemctl list-units —type service //to check service name
[root@localhost ~]# systemctl status openvpn-server@server.service // for me the service is «openvpn-server@server.service»
[root@localhost ~]# systemctl restart openvpn-server@server.service // to restart the service
i hope that will help
5 posts • Page 1 of 1
- Announcements
- Forum & Website Support
- Community Project
- ↳ Server Administration
- ↳ Configuration
- ↳ Examples
- ↳ Routed Example
- ↳ Installation Help
- ↳ Tutorials
- ↳ Testing branch
- ↳ Scripting and Customizations
- ↳ Authentication Scripts
- ↳ Routing and Firewall Scripts
- ↳ Rolling Your Own Installer
- ↳ Wishlist
- ↳ Cert / Config management
- ↳ Easy-RSA
- OpenVPN Inc. enterprise business solutions
- ↳ The OpenVPN Access Server
- ↳ CloudConnexa (previously OpenVPN Cloud)
- ↳ OpenVPN Connect (Windows)
- ↳ OpenVPN Connect (macOS)
- ↳ OpenVPN Connect (Android)
- ↳ OpenVPN Connect (iOS)
- Off Topic, Related
- Braggin’ Rights
- ↳ My VPN
- ↳ Doh!
- Pay OpenVPN Service Provider Reviews/Comments
- HomeBoard index
- All times are UTC
- Delete cookies
How to restart openvpn service (or any service) running under «nobody» user?
On my Ubuntu 16.04 server, I have the OpenVPN service running as the user nobody . How can I restart the service or reload the config file for the service using, for instance, systemctl ? An openvpn process is running, but I don’t know how to access it.
310 nobody 20 0 44440 3184 1968 S 0.0 0.3 1263:30 openvpn
The command su nobody does not work because no password is set. Is there an alternative?
4,749 5 5 gold badges 27 27 silver badges 54 54 bronze badges
asked Aug 20, 2017 at 20:28
193 1 1 gold badge 1 1 silver badge 8 8 bronze badges
7 Answers 7
Try this, I’ve noticed that restart doesn’t work for me.
sudo systemctl stop openvpn@server sudo systemctl enable [email protected] sudo systemctl start openvpn@server
1,887 28 28 gold badges 22 22 silver badges 24 24 bronze badges
answered May 30, 2018 at 16:53
William-Jack Dalessandro William-Jack Dalessandro
151 1 1 silver badge 3 3 bronze badges
OpenVPN is a templatized service under systemd . The services are named openvpn@config.service . So you should restart your /etc/openvpn/myvpn.conf instance with:
systemctl restart openvpn@myvpn.service
4,749 5 5 gold badges 27 27 silver badges 54 54 bronze badges
answered Aug 20, 2017 at 20:46
Hunter.S.Thompson Hunter.S.Thompson
275 1 1 silver badge 9 9 bronze badges
The trouble is using systemctl status [email protected] doesn’t reveal an active service when doing this under my login or under root user, as I assume the service is running under the nobody user
Aug 20, 2017 at 22:30
Go to the this directory and take a look at files:
sudo su cd /etc/systemd/system/multi-user.target.wants ls
there should be a file in this format (could be different depend on openvpn version):
if you see multiple files in this format, it’s because you probably use this code before:
this self-made files (created by enable) does nothing and could be removed later. But for now you should find the one works well with this commands without causing any error:
sudo systemctl stop [email protected]> sudo systemctl start [email protected]>
and replace with all files in this format (starts with openvpn and ends with .service) in the directory. The one that truly stops and starts openvpn service is the file you need and others could be removed (you shouldn’t have made them in first place by enabling them):
Be careful to not to remove the one that is making the service start and stop