You will need to open ports on your router for your server to be able to connect to stats, the master server list, and for other people to be able to connect to it. The ports you need to open are:
- 7777 and 7778, UDP Traffic (default game ports)
- 7787 and 7788, UDP Traffic (default Gamespy query port; +10 from game port)
- 28900, UDP Traffic (Master Server List Uplink)
- 28902, UDP Traffic (Master Server List Uplink)
- Web Admin Port, TCP Traffic (whatever port you assigned for Web Admin access in you UT2004.ini file - this may not be necessary if you're not using Web Admin)
This is what the setup looks like on my Linksys BEFW11S4 router. The W.A.P. is the Web Admin Port (assigned by you in the UT2004.ini file), and the IP is the inside (private) IP address of your game server.

When you "open" these ports, you're really just forwarding these ports. What you need to do is access your router, and go to the section called port forwarding or forwarding (something like that depending on our router model and brand). What you will do is allow incoming access from the internet to pass through these specific ports to the IP address of your game server. For the sake of saving yourself the brain damage, I suggest configuring your UT2004 server as a static IP address. This is a better setup than DHCP because DHCP can change the IP addresses of your network clients. Since you'll be doing port forwarding to a single, static IP address within your router, if your UT2004 server IP address changes, the port forwarding you setup is now useless.
** UPDATE **
I recently had to change my game port because I was getting hammered by bogus connection requests on port 7777. This seems very simple as the port is listed in the UT2004.ini file....all you should have to do is change that port. When I changed my port 7777 to any other number, the server refused to boot. I looked at the rather cryptic readout of the crash and I could tell it was somehow related to the Gamespy connection(s). When I searched for the relevance of this, I found out that I also needed to change the default Gamespy port (7787 default). When you start the server, it assign a port 10 ports ahead of your game port for Gamespy (this is why the default Gamespy port is 7787 when the game port is 7777). So, when I searched the UT2004.ini file for a section on the Gamespy port, I noticed it was hard set to 7787. This will *only* work when your game port is 7777. So, when I changed my game port from 7777 to something else, the server would crash when it tried to establish communication with Gamespy. All I had to do is change this port from 7787 to a number 10 ports ahead of my new game port.
Here is the section of UT2004.ini where it is located:
[IpDrv.UdpGamespyQuery]
MinNetVer=0
OldQueryPortNumber=7787
bRestartServerOnPortSwap= False (The default here is true which is what cause a forced restart or crash when I changed from port 7787)