Restart router in failsafe mode (differs by router, but for the WRT54GL and other linksys):
1. restart router, when DMZ light comes on, hold reset for 3 seconds until DMZ light starts flashing.
2. at this point connect computer directly to port 1 on router.
3. give computer static ip of
4. restart networking on computer.
5. run: telnet -l root
Run ‘firstboot’
Run ‘sync’
Run ‘passwd’ to reset root password.
Fix computer networking and restart the router.
Now log in as normal.

to get static ip with ip tools:
Manual assignment
Enable the network interface:
# ip link set interface up

Assign a static IP address in the console:
# ip addr add IP_address/subnet_mask broadcast broadcast_address dev interface

For example:
# ip addr add broadcast dev interface

For more options, see man ip.
Add your gateway IP address like so:
# ip route add default via default_gateway

For example:
# ip route add default via