Under Self-Organizing Network (SON), there is a feature known as automatic neighbor relation (ANR).
Using ANR, two eNodeBs makes X2 connection dynamically, they learn to each other dynamically.
If you don't have SON in place then you have to provide static configurations to each eNodeB so that both eNodeBs establishes X2 connection.