Do you see these packets on your wan interface? then on the server you're pinging and the same for the reply leg? then on the wan interface on the way back?
You can track your packets and identify which leg is failing and therefore which part of your configuration is incorrect.
Otherwise, I can't tell you much more unless you share your configuration and the commands you ran to get to where you are. (The same set as what is in the article you referred to - hide passwords if needed)
ip tunnel add vti1 local XX.XX.XX.XX remote 0.0.0.0 mode vti key 42
sysctl -w net.ipv4.conf.vti1.disable_policy=1
ip link set vti1 up
ip route add 172.31.0.0/22 dev vti1
In the ip tunnel command, I think the remote is incorrect, it should be the gateway IP from you right config (rather than 0.0.0.0).
Also make sure that your right network is in fact 172.31.0.0 as per the ip route add (most likely the case, it's just been XX-ed). The previous could mean that the remote would be something like 172.31.0.1 (if your gateway if on .1 ).
After that, you'll need to track the packets on the wan interface and then on the machine that you are pinging (and back) and let us know where it breaks down as it may be related to something else like a firewall preventing packets from coming back.
All parameters have been checked, everything is working perfectly, except the vti . If you have any documentation or reference links for vti which work 100%, then let us know, it would be of great help! thank you in advance
The thing is that the article you are referencing works "100%" and so does vti with IPSec on my own routers.
I believe something in your setup is incorrect (marking, routing, firewall...) and you will need to troubleshoot it further to find it.
You have not answered my questions about tracing the ping packets and you are not providing me with feedback on the changes I suggested (like the remote setting), so there is not much I can work with here.
On a side note regarding documentation, If I remember correctly, I got most of my information from the strongswan documentation and mailing list:
https://lists.strongswan.org/pipermail/users/2016-July/009829.html (this is useful as it gives you a way to see the settings sent by charon for the interface creation and routing setup - and even a nice way to automate all that setup as opposed to the manual way in your article)
Thank you so much for your guidance, your rp filter command did help us and we added it to our sysctl configuration as well.We referred to the same links you have mentioned and they were really helpful.
As of now we could establish VTI and bind it with our IPSec tunnel and everything looks fine.
If we face any issues in future, shall seek your help
Thank you once again, your inputs were really helpful!