Best antenna for outdoor gateway?

Hi,
I read a lot about different antennas but I still have no clue which type is better for which environment.

I want to install a RAK2245 Raspbery Pi HAT (868 MHz) on a roof (8 m) in a suburban environment.
The nearest other gateway is at least 4 km away so I think a bit of range would be nice.

The RAK comes with a very small iPEX antenna.
Any suggestions for a replacement for reasonable costs? DIY is possible.

Check RAKs offerings. They have two reasonably priced options. There are reviews of the larger antenna available on this forum as well as at least one thread dedicated to antennas…

Think of an antenna as a balloon. An omni antenna provides coverage equidistant in all directions (subject to obstructions). Yagi antenna are the equivalent of squeezing the balloon.