^^ not bad advice. and if i can add to this. if you are playing on wifi. try to ensure there is no signal drop. any loss of packets will cause a disconnect. doing what you can to secure a good strength network is what's needed.
there can also be some applications that run in the background that sap internet packets at times. this may also cause you to get a lag then a disconnect shortly after.
You can download an app called Wifi Analyzer, and check what channels your network is on. It will show you on a graphic which channels you broadcast on, almost nobody bothers to change these settings and so it's very likely that several other routers broadcast in the same range. That can cause your own network to drop signals.
So even if you have a good router, it can still have issues. I just want to add that routers are a computer dedicated to sending information from your devices to the internet and across your network, a free one is likely a few generations old and even if it's not it's probably single core with not much memory. The Linksys is a quadcore ac router, linksys is a good brand but they are expensive. The nighthawk routers are about half the price.