For Internet service providers (ISPs), there are three common types of interconnection agreements : private peering, public peering and transit. One of the most important problems for a single ISP is to determine which other ISPs to interconnect with, and under which agreements. The problem can be then to find a set of private peering providers, transit providers and Internet exchanges (IXs) when the following input data are assumed to be given : a set of BGP addresses with traffic demands, and a set of potential service providers (Private peering/transit providers and IXs) with routing information, cost functions and capacities. The objective is to minimize the total interconnection cost. We show that the problem is NP-hard, give a mixed-integer programming model, and propose a heuristic algorithm. Computational experience with a set of test instances shows the remarkable performance of the proposed algorithm of rapidly generating near-optimal solutions.