It takes about two hours to travel from Dublin to Belfast on the Irish Rail. While Dublin is in the Republic of Ireland and Belfast is in Northern Ireland, which is part of the United Kingdom, the countries are considered a Common Travel Area and passports are not required for British and Irish citizens. If you are from a country outside of Ireland and Britain, keep your passport, and visa if necessary, with you on the train.
Booking Train Travel
To book a ticket from Dublin to Belfast, you'll get the best rates when you buy your ticket online. The Irish Rail website has a "Journey Planner" which allows you to enter your departure station, which is Dublin Connolly, and your arrival station, which is Belfast Central. Enter the dates you want to travel and the type of ticket you want. You can choose one way, return and even a weekly or monthly pass. You'll reserve your seat and then pay for your ticket. You can also book train travel in person at the Connolly station.