The 31-year-old announced he would be swapping the boots for wellies as he steps into the next chapter of his life.
Dunbar came through the ranks at Annan Rugby Club where he then moved to Selkirk before signing a professional contract with Glasgow Warriors.
He played 119 times and was also capped 31 times by the national side and scored seven tries, including a crucial double in Scotland’s Six Nations win over Italy in Rome in 2014.
He was released by Glasgow in 2019 and had spells playing top-flight rugby in England and France with Newcastle and Brive before deciding to call time on his career.
Dunbar — who last year studied for an HND in agriculture by distance learning, having previously graduated in 2008 with an HNC from the Scottish Agricultural College in Ayrshire — said: “First week back on the farm complete. Feel extremely grateful to have had such an amazing journey with my rugby career. As a teenager growing up on the farm and playing rugby for fun, I’d never have imagined what it would lead to.
“I’ve been honoured to represent my country, play with and learn from legends of the game, travel to places I’d never of had the opportunity to before and most importantly make friendships that will last a lifetime.
“Unfortunately, my career has had to come to an end sooner than hoped due to injury but I’m happy and ready to move onto the next chapter of life with my family. Time to hang up the boots and pull on the wellies!”