Solved gateways and routing

I'm trying to get my FreeBSD system set up with a real IP address but am struggling to work out what I need to configure to be able to access the outside world. My ADSL modem/router is set up with a real IP address as is my Windows laptop on which I am writing this post, but I can't figure out what I need to do on my FreeBSD system. I can ping my FreeBSD system from my laptop but not vice versa. The FreeBSD machine can ping the modem/router, but anywhere beyond results in:

Code:
ping: sendto: No route to host
 
Well, for starters; how is your Windows laptop configured? I assume it uses DHCP (so a dynamic configuration)? If so then my advice would be to start there; do the same on FreeBSD. This could be a good read for that.
 
Every system that wants to make connections beyond the directly connected networks (the internet in other words) must have a default route on their routing table. In FreeBSD when you're not using DHCP this is done by setting the defaultrouter setting in rc.conf(5). Let's say the LAN address of your router is 192.168.1.1 then the correct setting would be:

Code:
defaultrouter="192.168.1.1"

There is no need to reboot after adding that setting, you can simply do service routing start.

You will know if the default route has been set by looking at the routing table with netstat -nr and checking if there's an entry that has default in the first column. This is from one of my systems as an example:

Code:
$ netstat -nr
Routing tables

Internet:
Destination        Gateway            Flags      Netif Expire
default            10.71.14.1         UGS      vtnet0
10.71.14.0/24      link#1             U        vtnet0
10.71.14.12        link#1             UHS         lo0
127.0.0.1          link#2             UH          lo0

In my case the default entry has a gateway of 10.71.14.1 that means simply that the default gateway for this system is 10.71.14.1.
 
Keep in mind that you probably only have one IP address. So you cannot have both your Windows and your FreeBSD machine use the same 'real' IP address.
 
Well, for starters; how is your Windows laptop configured? I assume it uses DHCP (so a dynamic configuration)? If so then my advice would be to start there; do the same on FreeBSD. This could be a good read for that.

No, my Windows laptop is set up with a static IP with the default gateway being the IP address of my ADSL modem/router which also has a real IP address.
 
Well what IP, netmask and gateway does your Windows machine actually have?

The gateway is my modem's address 213.152.37.89 FreeBSD has 90 and Windows laptop 91.

Netmask is 255.255.255.248.

There is something missing in the FreeBSD configuration
 
Ok, so you should have the following on your FreeBSD machine:

/etc/rc.conf
Code:
ifconfig_em0="inet 213.152.37.90 netmask 255.255.255.248"
defaultrouter="213.152.37.89"
(Replace em0 with whatever your actual interface is called)


As mentioned by kpa, your "No route to host" error screams of a missing default route/gateway.
Make sure you can ping the gateway from the FreeBSD machine. Not being able to ping the Windows machine is probably firewall on the laptop. If it still doesn't work then I believe you may have other problems than FreeBSD configuration. This is a pretty simple set up really, and the laptop working suggests that the router is configured correctly.

If you want hostnames to work, you'll also need a DNS server in /etc/resolv.conf.
 
It doesn't make a difference if you have only one public IP address with NAT (as I do) or if you have multiple public IP addresses, the same principles apply. Your host still needs a default route to access networks beyond the directly connected networks.
 
You don't specify what command you ran to "restart the network".
When changing routing options in /etc/rc.conf, you need to restart routing, which is what the /etc/rc.d/routing rc script does. You can run it directly as you did, or using service() as specified by kpa right at the start of the thread.

Code:
service routing restart

If you haven't come across service, it's basically just a simple wrapper than runs the specified /etc/rc.d/ or /usr/local/etc/rc.d/ script.
 
I restarted the network using /etc/rc.d/netif start. I have used service before but have never been sure what it can be used with.
 
Back
Top