This paper studies a model in which banks decide on the projects in which they invest, and the banks to which or from which they obtain loans. Thus, the links (network) created between banks is endogenous. Each bank is characterized by parameters which define the return on its projects, the withdrawal rate of its depositors and its equity available for investments. Maturity mismatch of balance sheets forces a fraction of assets to be prematurely liquidated, at a fire sale cost. The paper focuses on the impact of government intervention, which alleviates this cost by increasing the recovery rate of assets. The fragility of a network is measured by the number of bank failures following shocks of two kinds: first a shock to a single bank, second a simultaneous shock to all banks. The first leads to a ranking of the banks similar to that used by Google to rank websites: the higher its ranking the greater the degree of vulnerability induced by the bank. The vulnerability of the network to simultaneous shocks depends on the probability distribution of the banks characteristics: the more dispersed the distribution the greater its vulnerability. Government intervention increases the vulnerability of the network, the increase being greater the more dispersed the characteristics of the banks. Banking systems with similar leverage can have different degrees of vulnerability, highlighting the importance of networks.