Назад | Перейти на главную страницу

Невозможно ioctl TUNSETIFF tap0: устройство или ресурс занят (errno = 16)

У меня такая странная проблема, что когда я запускаю bridge-start вместе с openvpn, служба не запускается. Если я не позволю openvpn запустить bridge-start и добавить необходимые интерфейсы (tap0, br0) вручную (или запустить bridge-start из оболочки), я закомментирую директивы «up», чтобы openvpn не запускал никаких скрипт, то он работает и все в порядке.

Заглянув в журнал openvpn.log, я вижу, что openvpn вызывает сценарий с несколькими параметрами (/ etc / openvpn / bridge-start tap0 1500 1654 init), и я действительно не понимаю, почему это так. Могло ли это быть проблемой?

openvpn.log: Tue May 8 20:18:34 2018 us=217442 Current Parameter Settings: Tue May 8 20:18:34 2018 us=217576 config = 'server.conf' Tue May 8 20:18:34 2018 us=217599 mode = 1 Tue May 8 20:18:34 2018 us=217616 persist_config = DISABLED Tue May 8 20:18:34 2018 us=217633 persist_mode = 1 Tue May 8 20:18:34 2018 us=217679 show_ciphers = DISABLED Tue May 8 20:18:34 2018 us=217697 show_digests = DISABLED Tue May 8 20:18:34 2018 us=217713 show_engines = DISABLED Tue May 8 20:18:34 2018 us=217729 genkey = DISABLED Tue May 8 20:18:34 2018 us=217745 key_pass_file = '[UNDEF]' Tue May 8 20:18:34 2018 us=217761 show_tls_ciphers = DISABLED Tue May 8 20:18:34 2018 us=217778 connect_retry_max = 0 Tue May 8 20:18:34 2018 us=217795 Connection profiles [0]: Tue May 8 20:18:34 2018 us=217812 proto = udp Tue May 8 20:18:34 2018 us=217829 local = '[UNDEF]' Tue May 8 20:18:34 2018 us=217845 local_port = '1194' Tue May 8 20:18:34 2018 us=217861 remote = '[UNDEF]' Tue May 8 20:18:34 2018 us=217877 remote_port = '1194' Tue May 8 20:18:34 2018 us=217893 remote_float = DISABLED Tue May 8 20:18:34 2018 us=217909 bind_defined = DISABLED Tue May 8 20:18:34 2018 us=217925 NOTE: --mute triggered... Tue May 8 20:18:34 2018 us=217949 268 variation(s) on previous 20 message(s) suppressed by --mute Tue May 8 20:18:34 2018 us=217974 OpenVPN 2.4.5 x86_64-redhat-linux-gnu [Fedora EPEL patched] [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Mar 1 2018 Tue May 8 20:18:34 2018 us=218005 library versions: OpenSSL 1.0.2k-fips 26 Jan 2017, LZO 2.06 Tue May 8 20:18:34 2018 us=218268 NOTE: when bridging your LAN adapter with the TAP adapter, note that the new bridge adapter will often take on its own IP address that is different from what the LAN adapter was previously set to Tue May 8 20:18:34 2018 us=218467 NOTE: the current --script-security setting may allow this configuration to call user-defined scripts Tue May 8 20:18:34 2018 us=219618 Diffie-Hellman initialized with 2048 bit key Tue May 8 20:18:34 2018 us=221006 Outgoing Control Channel Authentication: Using 512 bit message hash 'SHA512' for HMAC authentication Tue May 8 20:18:34 2018 us=221065 Incoming Control Channel Authentication: Using 512 bit message hash 'SHA512' for HMAC authentication Tue May 8 20:18:34 2018 us=221120 TLS-Auth MTU parms [ L:1654 D:1140 EF:110 EB:0 ET:0 EL:3 ] Tue May 8 20:18:34 2018 us=221554 TUN/TAP device tap0 opened Tue May 8 20:18:34 2018 us=221605 TUN/TAP TX queue length set to 100 Tue May 8 20:18:34 2018 us=221798 /etc/openvpn/bridge-start tap0 1500 1654 init Tue May 8 20:18:34 2018 ERROR: Cannot ioctl TUNSETIFF tap0: Device or resource busy (errno=16) Tue May 8 20:18:34 2018 Exiting due to fatal error RTNETLINK answers: File exists RTNETLINK answers: File exists Tue May 8 20:18:34 2018 us=249873 WARNING: Failed running command (--up/--down): external program exited with error status: 2 Tue May 8 20:18:34 2018 us=249933 Exiting due to fatal error

мост-старт: br="br0" tap="tap0" eth="enp1s0" eth_ip="10.50.0.4" eth_netmask="24" eth_broadcast="10.50.0.255" for t in $tap; do /usr/sbin/openvpn --mktun --dev $t done /usr/sbin/ip link add $br type bridge /usr/sbin/ip link set $eth master $br for t in $tap; do /usr/sbin/ip link set $t master $br done for t in $tap; do /usr/sbin/ip link set $t up /usr/sbin/ip link set $t promisc on done /usr/sbin/ip link set $eth up /usr/sbin/ip link set $eth promisc on /usr/sbin/ip address add $eth_ip/$eth_netmask broadcast $eth_broadcast dev $br

sever conf:

port 1194 proto udp dev tap0 script-security 2 up "/etc/openvpn/bridge-start" down "/etc/openvpn/bridge-stop" tls-server ca ca.crt cert home-vpn.crt key home-vpn.key # This file should be kept secret dh dh2048.pem ifconfig-pool-persist ipp.txt server-bridge 10.50.0.4 255.255.255.0 10.50.0.50 10.50.0.100 push "redirect-gateway def1 bypass-dhcp" push "dhcp-option DNS 1.1.1.1" keepalive 10 120 tls-auth ta.key 0 # This file is secret auth-nocache cipher CAMELLIA-256-CBC auth SHA512 reneg-sec 3600 crl-verify crl.pem tls-version-min 1.2 tls-cipher TLS-DHE-RSA-WITH-AES-256-GCM-SHA384:TLS-DHE-RSA-WITH-AES-256-CBC-SHA256:TLS-DHE-RSA-WITH-AES-128-GCM-SHA256:TLS-DHE-RSA-WITH-AES-128-CBC-SHA256 compress lz4-v2 push "compress lz4-v2" max-clients 50 persist-key persist-tun status openvpn-status.log log-append openvpn.log verb 4 mute 20 explicit-exit-notify

Спасибо!

Это происходит, если вы не остановили службу openvpn и сразу внесли изменения в файл конфигурации - в результате после перезапуска у вас все еще остается потерянный процесс со старым интерфейсом. Необходимо полностью остановить службу openvpn и выполнить killall openvpn. - пример для Linux Debian:

# /etc/init.d/openvpn stop
# killall openvpn

Проверяем процесс в памяти:

# ps -A|grep openvpn

если нет - запускаем openvpn:

# /etc/init.d/openvpn start

сервис должен запуститься без ошибок ... :)