No, it isn’t compulsory to have the two because a router can function without a modem. You can use a modem (in the absence of a router) when you only need to connect to one device. Routers are ideal for connecting more than one device to the internet.