I am able to create static l2tpv3 tunnels using the following command:
ip l2tp add tunnel tunnel_id 90 peer_tunnel_id 1 udp_sport 5016 udp_dport 5017 encap udp local 172.16.0.1 remote 172.16.0.10
And it will work. But sometimes, when connectivity to the remote site goes up and down a few times, after stable connectivity is restored the tunnel will stop passing traffic.
Then I attempt to delete the tunnel using:
ip l2tp del tunnel tunnel_id 90
And the session and tunnel are deleted as verified by:
ip l2tp show tunnel
ip l2tp show session
Also the l2tpethx interface is also gone.
However, when I attempt to recreate the tunnel, using the exact same command as I initially did, this is the result:
# ip l2tp add tunnel tunnel_id 90 peer_tunnel_id 1 udp_sport 5016 udp_dport 5017 encap udp local 172.16.0.1 remote 172.16.0.10
RTNETLINK answers: Operation not permitted
Changing the tunnel id will not have any effect. However, if I change the port numbers or the remote IP address, I am able to create the tunnel.
What is lingering after I delete a tunnel that is preventing me from creating it again? How can I get rid of whatever is lingering?
Or even better, why does the tunnel stop passing traffic in the first place?
This isn't really an OpenL2TP question - OpenL2TP does not support L2TPv3. But I'll do my best to answer.
What commands do you use to create and delete sessions? My guess is one or more sessions still exists in the original tunnel.
You can show kernel state using debugfs.
# modprobe l2tp_debugfs
# mount -t debugfs debugfs /path/to/debugfs/mountpoint (might not be needed if debugfs is already mounted)
# cat /path/to/debugfs/mountpoint/l2tp/tunnels
If the kernel has state about tunnels or sessions, it will be displayed by the above command.