How would the Internet work between planets?
There would be special protocols for interplanet communication. Right now there are already different routing protocols for connecting different cities, different countries and different continents.

BGP (Border Gateway protocol) is a routing protocol used between continents mainly. It has different parameters and behavior than OSPF or RIP or other protocols used between different LAN's or WAN's.

Read about BGP. Some other protocols would probably be developed for even larger distances and for connecting different planets.