There are a few ways to play online depending on your platform.
Xbox and PS3 have their own online services which you must pay a monthly fee to use.
On PC you have a few options. You can play via a normal LAN which requires you and your teammates to be on the same network. You can also play via gamespy, which is a gaming network similar to steam which networks games together. You have to host the game on your local machine and in order to play Borderlands online via gamespy you need to open certain ports on your computer. The ports are as follows:
Foward all traffic on port 7777 to 7777 (TCP & UDP)
Forward TCP traffic on port 28900 to 28910 (TCP)
Forward UDP traffic on port 27900 to 27900 (UDP)
Direct all traffic on above ports to your local ip.
Your local ip is the internal ip your router assigns you. If you're using a router this will be 192.168.1.XXX. If you're not using a router you'll need to forward those ports through your firewall. If you're using a router you'll need to make sure that the computer you're playing Borderlands on is using a static IP instead of DHCP (Random IP). You can do this through your router's settings. To avoid duplicating IPs with others on your network I suggest setting your local ip as 192.168.1.121
If you have trouble forwarding ports http://forum.portforward.com/YaBB.cgi?num=1257007194
If don't wish to forward ports and/or you cant there is a work around. It is a virtual lan program called GameRanger. It allows you to host multiplayer games as if you were in the same room with the people you're playing with. It does not require any ports to be forwarded but can mess with internet connectivity of other users on your network.