The "
no route to host" error indicates that there's something wrong with your routing table. To be even more precise: I think that you never set up a so called "default route".
TCP/IP networking 101: When you set up your NIC with an IP address and network mask then your server will know that it belongs to a network which size is defined by the network mask. Example:
10.0.1.25/255.255.255.0. As such I know that this network range stretches between
10.0.1.1 and
10.0.1.255 (that's the basic theory at least, I'm skipping specifics). How do I know? Because of those 255's which tell me that the corresponding part of the IP address can't change. So only the 0 provides maximum "change", thus 1 - 255 (in theory at least).
So how does this setup know how to reach anything beyond this local network? The default route:
Code:
peter@zefiris:/home/peter $ netstat -4rn
Routing tables
Internet:
Destination Gateway Flags Netif Expire
default 10.0.1.1 UGS em0
10.0.1.0/24 link#1 U em0
10.0.1.5 link#1 UHS lo0
127.0.0.1 link#2 UH lo0
See? It knows that
em0 (the link itself) is supposed to be used to access the 10.0.1.0/24 network. Anything beyond that gets sent off to
10.0.1.1.
If I wouldn't have this default rule in place then my system would only know how to access the local network. Anything beyond that.... there would
literally be no route to that host.
So your solution?
Either set up your system to use DHCP as mentioned by the others above, this will usually set everything up for your automatically. OR... Find out the IP address of the router and add that manually.
On the command line you'd use:
# route add default <IP address>
.
And to make sure this is set up automatically during boot you'd add:
Code:
defaultrouter="<IP address>"
...to your
/etc/rc.conf file. Where you'd obviously need to replace that with your actual router address.