Setup of Router machine with FreeBSD

nvidican at nvidican at
Tue Jan 12 13:16:49 UTC 2010


The key thing you need to look at is enabling routing on the machine  
you want to act as a gateway. Given the dual-homed nature of the  
machine it's routing table will already contain each of the interfaces  
on the two networks, and as such the router machine will 'know' how to  
connect to each of the networks it is on. What is missing, is that you  
must tell the router machine that it can relay information across  
these known networks for other hosts.

As with most things, there's better documentation available on the  
subject, and I'd HIGHLY recommend you try reading the following  
handbook section 'Gateways and Routes' for a better understanding:

Within that section, it will elaborate as to how you can turn on and  
off the function to act as a gateway for other hosts. As in my  
original email reply to the list, the specific command is 'sysctl'  
which allows you to tune key variables controlling the kernel  
functionality - in this case, the behavior of acting as a gateway.

Please take a few moments and read through that section, it should  
greatly clarify some things for you. As always, feel free to ask again  
if you need further help with something.

Regarding your ping problem; are you using the correct cabling to go  
from ethernet card to card? You must use cross cables for direct  
connections, and straight-through if using a hub or switch. Assuming  
that you have no firewall in place blocking traffic, then ping should  
work fine - I would suggest you check your cabling first and go from  
there. Running the command 'ifconfig -a' will list your active network  
interfaces and should show the 'media state' as being connected and at  
what speed/duplex - check there first and work your way back.

Hope this helps.

Nathan Vidican
nathan at

Quoting Paul Shi <shihang at>:

> Nathan,
> Thank you very much for your reply.
> I have tried out your suggestion and experienced some problem. Hope you
> could kindly shed some light on them and I really appreciate it.
> First, I experienced connection problem from server machine( to
> router interface ( I connected the two network cards with
> standard Internet cable and tried to ping each other. However, it output
> following message which makes me think the connection between server and
> router is problematic;
> PING sendto Host is down.
> Any idea why this is happening? I think "ping" should work as long as I set
> the IP of network cards correctly and connect them with cable.
> Second, I am confused about the setup at the router machine. How the router
> machine figures out the relationship between and if
> we do not configure it to do so? Is there anything needs to be done besides
> adding route at server machine and client?
> Thank you very much for your kind attention! Have a nice day!
> Your sincerely,
> Paul Shi
> Electronic and Communication Engineering Senior
> Department of Electrical and Electronic Engineering
> University of Hong Kong
> On Mon, Jan 11, 2010 at 11:44 PM, <nvidican at> wrote:
>> Quoting Paul Shi <shihang at>:
>>  Dear All,
>>> I have tried to setup a wireless network consist of a server, AP, a router
>>> machine and wireless client. Here is setup and configuration of my design.
>>> Please correct me if I am wrong about anything.
>>> Server
>>> IP:, Gateway:, Netmask:
>>> ---------------------------------------------------------------------------------------------
>>> IP:,                                   Netmask:
>>> Router
>>> IP:,                                   Netmask:
>>> ---------------------------------------------------------------------------------------------
>>> IP:, Gateway:, Netmask:
>>> Access Point
>>> ---------------------------------------------------------------------------------------------
>>> IP:,                                  Netmask:
>>> Client
>>> I have add following to /etc/rc.conf of server machine
>>> static_routes="serverinternal"
>>> routes_serverinternal="'-net"
>>> and following to /etc/rc.conf of router machine
>>> static_routes="internal"
>>> routes_internal="'-net"
>>> Is there anything I have done wrong? Or anything else I need to do. My
>>> problem now is I cannot connect from server to router machine. Any
>>> suggestion would be greatly appreciated!
>>> Your sincerely,
>>> Paul Shi
>>> Electronic and Communication Engineering Senior
>>> Department of Electrical and Electronic Engineering
>>> University of Hong Kong
>>> _______________________________________________
>>> freebsd-questions at mailing list
>>> To unsubscribe, send any mail to "
>>> freebsd-questions-unsubscribe at"
>> Paul,
>> It seems to me your problem is in your route configuration. "
>>" is incorrect, /24 indicates the bitmask; the network
>> address should be correctly written as "" instead indicating
>> a network address of '' with a network of 254 usable IP addresses
>> in the same subnet.
>> You'll thus only have to have ONE route entry for the whole network, not
>> one per IP (unless that is your intention -in which case the '-net' syntax
>> is incorrectly being used). So long as routing is turned on (man sysctl),
>> simply pointing the server to the router and the client to the router to
>> connect to each other should work. Try doing the commands from the console
>> first to get it all working, then worry about putting in the startup configs
>> on boot-up.
>> Given your example, I'd login to 'server' and run:
>> route add
>> (if the router is the ONLY router from the server, use this instead):
>> route add
>> Then, from the client, add:
>> route add
>> The gateway/router box itself does not need any routing setup internally;
>> you don't need/shouldn't be setting any routes given that, and
>> are hosts on the two networks for which you want to allow
>> routes. They key is in getting the clients to both use the same gateway, (as
>> accessible from the network they are respectfully on). This may be a little
>> more clearly depicted below:
>> Host A ( <--> Router ( ( <--> Host B
>> (
>> Host A:
>>  - needs to know to use '' as it's gateway to
>>  - may just use as it's default gateway to ANY network
>> Host B:
>>  - needs to know to use '' as it's gateway to
>>  - similarly, may just use '' as it's default gateway to ANY as
>> well
>> Assuming you're connecting the internet at some point to the gateway
>> (router) machine, a decent firewall filter and NAT will most likely be
>> required as well. Read up in the handbook a bit on the subject or feel free
>> to come back for more info if needed.
>> Hope this helps.
>> --
>> Nathan Vidican
>> nathan at
> _______________________________________________
> freebsd-questions at mailing list
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at"

More information about the freebsd-questions mailing list