이 tun 인터페이스를 어떻게 종료할 수 있나요?

이 tun 인터페이스를 어떻게 종료할 수 있나요?

tun시작 시 추가된 이 인터페이스를 종료하거나 삭제할 수 없습니다 .

내가 실행할 때의 출력은 다음과 같습니다 ifconfig.

eth0      Link encap:Ethernet  HWaddr 50:b7:c3:92:38:e2  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:38993 errors:0 dropped:0 overruns:0 frame:0
          TX packets:38993 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:5827743 (5.8 MB)  TX bytes:5827743 (5.8 MB)

tun       Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet6 addr: <some ipv6 address, hidden for privacy>/128 Scope:Global
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1280  Metric:1
          RX packets:2772 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2301 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:1883371 (1.8 MB)  TX bytes:216571 (216.5 KB)

virbr0    Link encap:Ethernet  HWaddr f2:49:d0:5b:ef:80  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr c8:f7:33:ac:34:56  
          inet addr:192.168.219.130  Bcast:192.168.219.255  Mask:255.255.255.0
          inet6 addr: fe80::caf7:33ff:feac:3456/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1586404 errors:0 dropped:0 overruns:0 frame:0
          TX packets:909338 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2115233714 (2.1 GB)  TX bytes:95329457 (95.3 MB)

인터페이스를 사용하면 tun터널을 통해 IPv6 네트워크에 액세스할 수 있지만 IPv4보다 IPv6 네트워크를 우선시하고 해당 터널을 통해 웹 서버에 연결을 시도하는 시스템 동작으로 인해 속도가 너무 느려집니다.

비활성화하려고 실행했는데 sudo ifconfig tun down다음과 같은 결과가 나타났습니다.

$ sudo ifconfig tun down
[sudo] password for theuser: 
$ sudo ifconfig tun
tun       Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
      POINTOPOINT NOARP MULTICAST  MTU:1280  Metric:1
      RX packets:3250 errors:0 dropped:0 overruns:0 frame:0
      TX packets:2730 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:500 
      RX bytes:2194591 (2.1 MB)  TX bytes:264663 (264.6 KB)

$ sleep 10
$ sudo ifconfig tun
tun       Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
      inet6 addr: 2001:5c0:1400:a::d9/128 Scope:Global
      UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1280  Metric:1
      RX packets:6 errors:0 dropped:0 overruns:0 frame:0
      TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:500 
      RX bytes:416 (416.0 B)  TX bytes:982 (982.0 B)

$   

몇 초 후에 다시 나타납니다! 더 나쁜 것은 해당 터널을 삭제하려고 하면 다음과 같습니다.

$ sudo ip tuntap del dev tun mode tun
ioctl(TUNSETIFF): Device or resource busy

놀랍게도 dmesg특별한 내용은 없는 것 같습니다.

[    0.997669] tun: Universal TUN/TAP device driver, 1.6
[    0.998470] tun: (C) 1999-2004 Max Krasnyansky <[email protected]>
[43633.762740] Loading kernel module for a network device with CAP_SYS_MODULE (deprecated).  Use CAP_NET_ADMIN and alias netdev-tun instead.
[43995.971465] Loading kernel module for a network device with CAP_SYS_MODULE (deprecated).  Use CAP_NET_ADMIN and alias netdev-tun instead.
[43996.550325] Loading kernel module for a network device with CAP_SYS_MODULE (deprecated).  Use CAP_NET_ADMIN and alias netdev-tun instead.
[44538.652492] Loading kernel module for a network device with CAP_SYS_MODULE (deprecated).  Use CAP_NET_ADMIN and alias netdev-tun instead.
[44630.584862] Loading kernel module for a network device with CAP_SYS_MODULE (deprecated).  Use CAP_NET_ADMIN and alias netdev-tun instead.
[44630.627822] Loading kernel module for a network device with CAP_SYS_MODULE (deprecated).  Use CAP_NET_ADMIN and alias netdev-tun instead.
[44630.744474] Loading kernel module for a network device with CAP_SYS_MODULE (deprecated).  Use CAP_NET_ADMIN and alias netdev-tun instead.
[44630.858219] Loading kernel module for a network device with CAP_SYS_MODULE (deprecated).  Use CAP_NET_ADMIN and alias netdev-tun instead.
...

편집하다: 명령을 실행하면 sudo ip link delete tun아무 것도 표시되지 않으며 단순히 작동하지 않습니다.

편집하다:

$ sudo tunctl -d tun
TUNSETIFF: Invalid argument
$

답변1

장치 tun0을 삭제하려면 다음을 사용했습니다.

sudo ip link set dev tun0 down

효과가 있었습니다.

답변2

제가 아는 한 IPv6 터널 소프트웨어는 기본적으로 설치되어 있지 않으므로 직접 설치해야 하며 해당 패키지를 다시 제거하면 충분합니다.

출력 에 구성된 IPv6 주소는 GOGO6( ) ifconfig에 할당된 블록에 속하므로2001:5c0:1000::/36고곡제거해야 하는 패키지입니다.

답변3

명령을 사용하여 tunctl먼저 패키지를 설치할 수 있습니다.

sudo apt-get install uml-utilities

그런 다음 tun 인터페이스를 삭제하려면 다음 명령을 사용하십시오.

sudo tunctl -d tun

다음을 살펴보세요 man tunctl:

Name

        tunctl - create and manage persistent TUN/TAP interfaces

-d  interfacename

        Delete the specified interfacename (set it to non-persistent)

관련 정보