Hearts, last season’s Scottish Championship winners. will face Arbroath, while Edinburgh rivals Hibernian will take on Montrose.
The tie against Peterhead will be new Rangers boss Mark Warburton’s first competitive fixture at Ibrox.
Peterhead were the first side the Gers faced on league duty after being demoted to the Scottish Third Division, with the sides playing out a 2-2 draw at Balmoor Stadium in August 2012.
The last time Rangers hosted the Blue Toon it was the away side who came out on top, winning the Scottish Third Division tie 2-1 at Ibrox in April 2013.
Elsewhere, last year’s beaten Scottish Cup finalists Falkirk will take on East Stirlingshire, while Livingston were handed a home tie against Clyde in an identical tie to their Petrofac Training Cup first round match.
Draw in full:
Falkirk v East Stirlingshire
Berwick Rangers v Alloa Athletic
Heart of Midlothian v Arbroath
Stirling Albion v Airdrieonians
Raith Rovers v Albion Rovers
Annan Athletic v Queen of the South
Livingston v Clyde
Dunfermline Athletic v Cowdenbeath
Hibernian v Montrose
East Fife v Dumbarton
Greenock Morton v Elgin City
Queen’s Park v Forfar Athletic
Stranraer v Stenhousemuir
Ayr United v Brechin City
Rangers v Peterhead
Ties to be played on Saturday, August 1.