Skip to content

stale-routes-check removes non-cached route table entries #1063

Description

@domdom82

Describe the bug

  • When using the stale-routes-check option, OpenVPN deletes all stale entries from the route table, including permanent routes that were added using iroute entries, e.g. from a client-config-dir file.
  • Once all permanent routes have been removed, new IP addresses from any of the iroute routes will no longer be forwarded through the VPN, creating an outage.

To Reproduce

  • Set up OpenVPN with mode tun, client-config-dir and stale-routes-check directive
  • Let a client connect and put some traffic using one of the iroute routes in the client-config through the VPN
  • Wait for the "clean" interval of the stale-routes-check to pass
  • Retry the same traffic from above
  • Traffic to the IP within the iroute does not work

Expected behavior

  • Only cached entries (with a C suffix) should be deleted
  • Traffic to the IP within the iroute network should work for all IPs, cached or not

Version information (please complete the following information):

  • OS: Ubuntu 26.04 LTS
  • OpenVPN version: 2.7 (2.7.0 up to 2.7.3)

Additional context

  • Sample openvpn server config:
mode server
tls-server
topology subnet

ca /cacert.pem
cert /cert.pem
key /key.pem
cipher AES-128-GCM
dh /dh2048.pem

max-routes-per-client 256

# Stale after 300s, Remove after 600s
stale-routes-check 300 600

client-config-dir /client-config-dir

dev tun0
server-ipv6 fd8f:6d53:b97a:1::100:0/112

keepalive 10 60
verb 3
proto tcp6-server

status /var/run/vpn-server.status 15
status-version 2
  • Sample client-config-dir contents:
# DEFAULT file in /client-config-dir 
iroute 242.0.0.0 255.0.0.0
iroute 243.0.0.0 255.0.0.0
iroute 244.0.0.0 255.0.0.0
  • Sample openvpn client config:
client
tls-client
pull

ca /cacert.pem
cert /vpn-client-0/cert.pem
key /vpn-client-0/key.pem

dev tun0
remote 192.168.100.100

keepalive 10 60
verb 3
  • Test procedure:
# INITIAL STATUS FILE

root@vpn-server-0:/# cat /var/run/vpn-server.status
TITLE,OpenVPN 2.7.0 aarch64-unknown-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] [DCO]
TIME,2026-06-22 15:16:54,1782141414
HEADER,CLIENT_LIST,Common Name,Real Address,Virtual Address,Virtual IPv6 Address,Bytes Received,Bytes Sent,Connected Since,Connected Since (time_t),Username,Client ID,Peer ID,Data Channel Cipher
CLIENT_LIST,vpn-client-0,tcp6-server:192.168.100.2:59016,,fd8f:6d53:b97a:1::100:2,4547,4805,2026-06-22 15:16:39,1782141399,UNDEF,0,0,AES-256-GCM
HEADER,ROUTING_TABLE,Virtual Address,Common Name,Real Address,Last Ref,Last Ref (time_t)
ROUTING_TABLE,244.0.0.0/8,vpn-client-0,tcp6-server:192.168.100.2:59016,2026-06-22 15:16:39,1782141399
ROUTING_TABLE,243.0.0.0/8,vpn-client-0,tcp6-server:192.168.100.2:59016,2026-06-22 15:16:39,1782141399
ROUTING_TABLE,fd8f:6d53:b97a:1::100:2,vpn-client-0,tcp6-server:192.168.100.2:59016,2026-06-22 15:16:39,1782141399
ROUTING_TABLE,242.0.0.0/8,vpn-client-0,tcp6-server:192.168.100.2:59016,2026-06-22 15:16:39,1782141399
GLOBAL_STATS,Max bcast/mcast queue length,1
GLOBAL_STATS,dco_enabled,0
END


# PING TARGET IN 244.0.0.0/8

root@vpn-server-0:/# ping 244.11.0.2
PING 244.11.0.2 (244.11.0.2) 56(84) bytes of data.
64 bytes from 244.11.0.2: icmp_seq=1 ttl=63 time=6.83 ms
64 bytes from 244.11.0.2: icmp_seq=2 ttl=63 time=0.405 ms
64 bytes from 244.11.0.2: icmp_seq=3 ttl=63 time=0.662 ms
64 bytes from 244.11.0.2: icmp_seq=4 ttl=63 time=0.293 ms
64 bytes from 244.11.0.2: icmp_seq=5 ttl=63 time=0.240 ms
^C
--- 244.11.0.2 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4055ms
rtt min/avg/max/mdev = 0.240/1.685/6.826/2.574 ms

# STATUS FILE NOW CONTAINS A CACHED ENTRY

root@vpn-server-0:/# cat /var/run/vpn-server.status
TITLE,OpenVPN 2.7.0 aarch64-unknown-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] [DCO]
TIME,2026-06-22 15:17:40,1782141460
HEADER,CLIENT_LIST,Common Name,Real Address,Virtual Address,Virtual IPv6 Address,Bytes Received,Bytes Sent,Connected Since,Connected Since (time_t),Username,Client ID,Peer ID,Data Channel Cipher
CLIENT_LIST,vpn-client-0,tcp6-server:192.168.100.2:59016,,fd8f:6d53:b97a:1::100:2,4755,5715,2026-06-22 15:16:39,1782141399,UNDEF,0,0,AES-256-GCM
HEADER,ROUTING_TABLE,Virtual Address,Common Name,Real Address,Last Ref,Last Ref (time_t)
ROUTING_TABLE,244.0.0.0/8,vpn-client-0,tcp6-server:192.168.100.2:59016,2026-06-22 15:16:39,1782141399
ROUTING_TABLE,243.0.0.0/8,vpn-client-0,tcp6-server:192.168.100.2:59016,2026-06-22 15:16:39,1782141399
ROUTING_TABLE,fd8f:6d53:b97a:1::100:2,vpn-client-0,tcp6-server:192.168.100.2:59016,2026-06-22 15:16:39,1782141399
ROUTING_TABLE,244.11.0.2C,vpn-client-0,tcp6-server:192.168.100.2:59016,2026-06-22 15:17:38,1782141458
ROUTING_TABLE,242.0.0.0/8,vpn-client-0,tcp6-server:192.168.100.2:59016,2026-06-22 15:16:39,1782141399
GLOBAL_STATS,Max bcast/mcast queue length,1
GLOBAL_STATS,dco_enabled,0
END

# see ROUTING_TABLE,244.11.0.2C,vpn-client-0,tcp6-server:192.168.100.2:59016,2026-06-22 15:17:38,1782141458


# NOW WAIT FOR 600s AS PER CONFIG FILE

sleep 10m

# RE-CHECK STATUS FILE

cat /var/run/vpn-server.status

TITLE,OpenVPN 2.7.0 aarch64-unknown-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] [DCO]
TIME,2026-06-22 15:28:13,1782142093
HEADER,CLIENT_LIST,Common Name,Real Address,Virtual Address,Virtual IPv6 Address,Bytes Received,Bytes Sent,Connected Since,Connected Since (time_t),Username,Client ID,Peer ID,Data Channel Cipher
CLIENT_LIST,vpn-client-0,tcp6-server:192.168.100.2:59016,,fd8f:6d53:b97a:1::100:2,7699,8787,2026-06-22 15:16:39,1782141399,UNDEF,0,0,AES-256-GCM
HEADER,ROUTING_TABLE,Virtual Address,Common Name,Real Address,Last Ref,Last Ref (time_t)
GLOBAL_STATS,Max bcast/mcast queue length,1
GLOBAL_STATS,dco_enabled,0
END

# ALL ENTRIES ARE GONE - NOW RETRY TO CONNECT VIA PING

root@vpn-server-0:/# ping 244.11.0.2
PING 244.11.0.2 (244.11.0.2) 56(84) bytes of data.
^C
--- 244.11.0.2 ping statistics ---
8 packets transmitted, 0 received, 100% packet loss, time 7146ms


# OUTAGE UNTIL RECONNECT

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions