Methods, systems, and apparatus, including computer programs encoded on computer storage media, for dynamic gateway selection. In some implementations, a first communication tunnel is established between an SD-WAN
router and a first SD-WAN gateway via a first
wireless gateway. After establishing and using a modem of the terminal to communicate through the first communication tunnel, determining that the modem switched to communicate with a second
wireless gateway that is different from the first
wireless gateway. In response, a second SD-WAN gateway is selected based on a relationship between the second
wireless gateway and the second SD-WAN gateway. Criteria for establishing an additional communication tunnel are determined to be satisfied. In response to determining that the criteria have been satisfied, a second communication tunnel between the SD-WAN
router and the second SD-WAN gateway is established, the terminal is configured to provide data through the first and the second communication tunnel.