Smart grids (SG) are essential for efficient management and monitoring of electric power networks. One of the most important tasks in SG focuses on fault detection and automatic network reconfiguration. This process allows minimizing power losses and load balancing in distribution networks. In this paper, an adaptation of the open shortest path first (OSPF) routing protocol to accomplish the network reconfiguration task is proposed. The algorithm is intended to run in secondary substation nodes over an agent-based distributed architecture. The proposed algorithm has been tested on the IEEE 123 modified node test feeder and on an actual grid deployed by an electrical distribution company. Moreover, a performance comparison with a typical centralized reconfiguration algorithm is carried out.