The Romans built a wall, actually two walls, there’s some question as to whether they wanted to keep the locals in and the Picts out or whether they were considering the more salient aspects of effective customs and excise. Whatever its main uses were, other than keeping Roman squaddies busy building it and then miserable guarding it, a nice solid stone (or soil and turf) structure with gates at regular intervals is quite hard to argue with.
During the medieval period the border between England and Scotland shifted depending upon the strength of the English and Scottish monarchs and,of course, what else was occupying their attention. During the Anarchy or the Nineteen Long Winters as the war between Stephen and Matilda in England was known the Scots were able to extend their borders in a southerly direction. Carlisle was in King David of Scotland’s hands at this time.
The reign of King John (a.k.a. Lackland or Softsword depending on how mean you’re feeling) is also a good example of Scottish kings availing themselves of convenient opportunities. In 1209 William I of Scotland and King John of England signed the Treaty of Norham which stopped the English building a fort at Tweedmouth, but at the cost of a £10,000 payment to the English: and William’s two oldest daughters, who John later married to English nobles. On the 4th December 1214 Alexander II succeeded to the Scottish throne and the following year took advantage of King John’s weakness after the signing of the Magna Carta to try to capture Northumberland. He was beaten back but a period of cross border warfare followed until John’s death in 1216.
In 1237 The Anglo-Scottish border was established at The Treaty of York but like most next door neighbours with a shared fence there was still some argument about who was responsible for what.
By 1244 cross border tension led to the betrothal of the three-year-old future Alexander III and four-year-old Margaret, daughter of Henry III. In October 1245 both kings sent men to agree where the border line lay from the Solway Firth in the West to the mouth of the River Tweed in the East so as to avoid any future unpleasantness. In total that’s between 97 and 120 miles, depending on what you’re reading, with lots of ups and downs. Six English knights and the six Scottish knights were sent off to ‘perambulate’ the borderline but weren’t able to agree. Twelve more knights were sent for a hike in December 1246. Again, what could have been a pleasant though rather lengthy walk turned into a rather undignified argument with the two nationalities unable to agree about which bits of land were Scottish and which were English. In the end Henry arranged for twenty-four knights to take a stroll and they all agreed. They were also all English which perhaps explains the unexpected harmony.