Australia is to hold a national gun amnesty, its first in more than two decades, in a bid to combat terrorism and a recent influx in illegal firearms.