Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jun 2009 12:48:21 -0600 (MDT)
From:      "Peter" <fbsdq@peterk.org>
To:        freebsd-questions@freebsd.org
Subject:   /etc/hosts - how does that file work?? - was weird nfs issues.
Message-ID:  <093ebf7d0b078a923d5690a42ef982e7.squirrel@webmail.pknet.net>

next in thread | raw e-mail | index | archive | help
iH,
  This all started with NFS not mounting at boot....so, testing in VMs:

This is a fresh/generic install of 7.2-REL
 no firewall
 em1=10.21.20.0/24 network - DHCP for ssh access

client# uname -a
FreeBSD client.test 7.2-RELEASE FreeBSD 7.2-RELEASE #0: Fri May  1
08:49:13 UTC 2009    
root@walker.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386


client# cat /etc/rc.conf
gateway_enable="YES"
hostname="client.test"
ifconfig_em0="inet 172.20.6.2  netmask 255.255.255.0"
ifconfig_em0_alias0="inet 116.23.45.2 netmask 255.255.255.0"
ifconfig_em1="DHCP"
nfs_client_enable="YES"
nfs_server_enable="NO"
rpcbind_enable="NO"
sshd_enable="YES"

client# ifconfig em0|grep inet
        inet 172.20.6.2 netmask 0xffffff00 broadcast 172.20.6.255
        inet 116.23.45.2 netmask 0xffffff00 broadcast 116.23.45.255
client# cat /etc/hosts
::1                     localhost localhost.test
127.0.0.1               localhost localhost.test

172.20.6.2              client.test client
116.23.45.2             client.test client

172.20.6.1              server.test server
116.23.45.3             server.test server
client# ping -c1 server
PING server.test (172.20.6.1): 56 data bytes
64 bytes from 172.20.6.1: icmp_seq=0 ttl=64 time=5.811 ms

--- server.test ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 5.811/5.811/5.811/0.000 ms
client# ssh -vvv server
OpenSSH_5.1p1 FreeBSD-20080901, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to server.test [116.23.45.3] port 22.
^C
client#
    ssh to 'server' always goes to 116.23.45.3 IP
     there is nothing on '116.23.45.3' IP
       '116.23.45.3/24' is a made up network for testing


BUT...


client# ifconfig em0|grep inet
        inet 172.20.6.2 netmask 0xffffff00 broadcast 172.20.6.255
        inet 116.23.45.2 netmask 0xffffff00 broadcast 116.23.45.255
client# cat /etc/hosts
::1                     localhost localhost.test
127.0.0.1               localhost localhost.test

172.20.6.2              client.test client
116.23.45.2             client.test client

172.20.6.1              server.test server
116.23.45.4             server.test server
client# ping -c1 server
PING server.test (172.20.6.1): 56 data bytes
64 bytes from 172.20.6.1: icmp_seq=0 ttl=64 time=0.285 ms

--- server.test ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.285/0.285/0.285/0.000 ms
client# ssh -vvv server
OpenSSH_5.1p1 FreeBSD-20080901, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to server.test [172.20.6.1] port 22.
debug1: Connection established.
...
......

Why if the secondary entry is higher than '116.23.45.3' it always goes to
172/24 network?

Why is ping using one IP, and ssh/mount_nfs/showmount using another IP
from /etc/hosts?


]confused[




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?093ebf7d0b078a923d5690a42ef982e7.squirrel>