The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]

FreeBSD Support
 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Newer Topic  |  Older Topic 
 how to run games through a freebsd gateway/router
Author: Pascal Zoutendijk 
Date:   30-10-00 22:45

Hi,

I recently installed freebsd at home to use it as a gateway for my internal network. When my firewall is setup up as "open", I have no problems playing Unreal tournament, but most of the other games just won't start a multiplayer session. When I set my firewall to "simple", none of the games comes through. I already figured out this had something to do with the ports on which the game server replies and I know that there are scripts like ip_masq_quakeII for linux, but I am wondering whether there were scripts like that for freebsd.

are those scripts hard to write for yourself? I hope not, because I play a lot of games and to write a new script for al of my games would be very time-consuming ;o), Or is it possible to add a rule to the firewall like ipfw add divert tcp from x{port} to y{internal adres of computer} ?????

Please help me out, give me examples!

thanx.

Reply To This Message
 
 RE: how to run games through a freebsd gateway/rou
Author: Dan Larsson 
Date:   31-10-00 12:03

You should try the *BSD type masq-type-solution, NATD.

Here's a shortlist of what you'd need to do to use it:

+ Recompile your kernel with the option IPDIVERT
+ Add the following to your /etc/rc.conf
gateway_enable="YES"
firewall_enable="YES"
firewall_type="SIMPLE"
natd_enable="YES"
natd_interface="<nic with real internet address>"
natd_flags="-f /etc/rc.natd"
+ Add a few basic things to your /etc/rc.natd file:
echo -e "same_ports
use_sockets
unregistered_only
dynamic" >
/etc/rc.natd
+ Reboot and enjoy!

This works for me!

Note that you're probably better off creating your own 'firewall_type' to suit
your needs better. To read more about this check out the man pages for
'ipfw' and 'natd'.

Reply To This Message
 
 RE: how to run games through a freebsd gateway/rou
Author: Dan Larsson 
Date:   31-10-00 12:15

Somehow the 'natd_interface' line got mangled (phorum doesn't like anglebrackets?)

The line should say:

natd_interface="EXTERNAL INTERFACE"

Replace the capital letters with the correct interface.

Reply To This Message
 
 RE: how to run games through a freebsd gateway/rou
Author: Pascal Zoutendijk 
Date:   04-11-00 21:52

Ok thanks for the help, however there are some things which I don't understand. Dan Larsson wrote:

+ Add a few basic things to your /etc/rc.natd file:
echo -e "same_ports
use_sockets
unregistered_only
dynamic" >
/etc/rc.natd

Am I right if I say that there should be " after the first rule and in front of the fourth rule???

Reply To This Message
 
 RE: how to run games through a freebsd gateway/rou
Author: Dan Larsson 
Date:   06-11-00 10:58

No. The quotes are only there because 'echo' is supposed to know there're
several lines.

Reply To This Message
 
 RE: how to run games through a freebsd gateway/rou
Author: Iain Patterson 
Date:   07-11-00 03:40

Some games use multiple ports. The Half-Life client, for instance, sends udp packets to a server on 27010 (if I recall correctly) and expects responses from that port (which is fine because natd will set up a dynamic rule for it) but also expects to receive udp packets from the server port 27015 (again, if I recall correctly). This means that you'll need to add a static rule to natd with "-redirect_port udp GAMES_MACHINE_LOCAL_IP:27015 27015". Depending on how paranoid your firewall is you might need to add accept rules for this traffic with something like "ipfw add accept udp from any 27015 to GAMES_MACHINE_LOCAL_IP" or ("echo pass in quick udp from any port = 27015 to GAME_MACHINE_LOCAL_IP | ipf -f" for IPFILTER) (When playing with these rules, remember that packets go through the firewall twice, once with destination IP of the external interface and once with that of the private IP).

A good way to find out which ports you need to hack is to run netstat on both your Windows box and the FreeBSD box and check the firewall logs to see what's trying to come in. This was the technique I used to figure out Half-Life. However there are sites out there that give you instructions for various games. http://www.tmservices.com/masq/catlist.php3?Games is a good one (Linux-centric, has commands for ipfwadm/ipchains) with a big list of games. Sadly I never did get Aliens v Predator to work...

Reply To This Message
 
 RE: how to run games through a freebsd gateway/rou
Author: Iain Patterson 
Date:   13-11-00 03:22

Correction: I never got AvP to work until this weekend, when I decided to have another crack at it using ipfilter (I was using ipfw before). Actually nice and easy:

nat.rules:
rdr tun0 REAL_IP/32 port 2300-2400 -> LOCAL_IP port 2300 tcp/udp

firewall.rules
pass in on tun0 proto tcp from any to LOCAL_IP keep state
pass in on tun0 proto udp from any to LOCAL_IP keep state
pass out on ep0 proto tcp from any to LOCAL_IP keep state
pass out on ep0 proto udp from any to LOCAL_IP keep state

Reply To This Message
 Forum List  |  Threaded View   Newer Topic  |  Older Topic 


 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Password:
 Remember my login:
   
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum

phorum.org