Harbors can provide the railroad bonus. All that is required is a full set of harbor-railroad connections to the capital. So, if you have an inland capital, RR connection from capital to City A with a harbor plus harbor connection to cities B and C on another landmass means Cities A, B and C will all have the RR bonus. If city C is then connected to city D by RR, city D also gets the RR bonus. Also, remember that your capital never gets RR bonus.