Is it a cable modem? A general rule with modems for getting an internet connection...
The modem will only recognize one device at a time (by its MAC address). If your router is connected, then it will recognize the router's MAC address. If you then switch to have your computer connected directly to the modem, then you'll have to power cycle the modem in order for it to recognize your computer's MAC address and communicate with it. To power cycle the modem, unplug it for a few minutes. If it has a battery backup, remove it.
In other words, if you've been playing around with the connections, switching between the router and the computer, you'll want to power cycle the modem each time you switch.