On Fri 05 Jul 2019 at 06:15:02 (-0400), Gene Heskett wrote:
> On Thursday 04 July 2019 23:38:50 andreimpope...@gmail.com wrote:
> > On Jo, 04 iul 19, 03:30:55, Gene Heskett wrote:
> > > On Thursday 04 July 2019 02:47:50 Andrei POPESCU wrote:
> > > > I seem to recall sudo cares about /etc/hosts.
> > >
> > > But I have that address TAB hostname.domain.name TAB alias in the
> > > hosts file. No errors there.
> >
> > How about showing us (attaching) the complete file ;)
> 
> Attaching is difficult, I had to remount the machine. But here it is.

> 127.0.0.1     localhost
> 192.168.71.1  router.coyote.den       router
> 192.168.71.3    coyote.coyote.den     coyote
> 192.168.71.4  shop.coyote.den         shop
> 192.168.71.5  lathe.coyote.den        lathe
> 192.168.71.6  lappy.coyote.den        lappy
> 192.168.71.7  sheldon.coyote.den      sheldon
> 192.168.71.10 GO704.coyote.den        GO704
> 192.168.71.12 picnic.coyote.den       picnc
> 192.168.71.21 MFC.coyote.den          printer scanner
> 192.168.71.30 vna.coyote.den          vna
> ::1           localhost ip6-localhost ip6-loopback
> ff02::1               ip6-allnodes
> ff02::2               ip6-allrouters
> 
> #127.0.1.1    raspberrypi

I'm reluctant to say much about your network configuration since you
wrote about having a managed switch as well as your router in your
"lashup", and also because I have no idea what you've "nuked".

My LAN is entirely static, with a master list of hosts,
/root/hosts-1-template, on my laptop, which I distribute to all the
others' /root directories and then mangle into place in /etc.
I don't try to fight dhcp in the router (which lacks a DNS server),
but just put all the hosts' MAC addresses into its Address Reservation
list (including things like printers, mobiles, Rokus and TVs).
Anything that appears as 192.168.1.200+ is a stranger.

I mangle the master list with two lines of bash (which sit in the
bash history file):

# cat /root/hosts-[0-9]-*[^~] | sed -e "/^[[:space:]]*192.168.1.[0-9]\+[[:spa
ce:]]\+$HOSTNAME.corp[[:space:]]\+$HOSTNAME\$/s/[[:space:]]*\([0-9.]\+\)[[:spa
ce:]]\+\(.*\)\$/127.0.1.1\t\2\t# \1/" | diff -U1 -bw - /etc/hosts | less

which checks any editing done on the master copies
/root/hosts-[0-9]-*[^~], and the same line, but ending with:

ce:]]\+\(.*\)\$/127.0.1.1\t\2\t# \1/" > /etc/hosts

to overwrite the real hosts file after checking. So:
127.0.0.1       localhost
192.168.1.1     router.corp     router
192.168.1.10    acer.corp       acer
gets turned into:
127.0.0.1       localhost
192.168.1.1     router.corp     router
127.0.1.1       acer.corp       acer    # 192.168.1.10
by sed when that line is run on the acer PC.

(I've split the line in the middle of "space", obviously, for posting
here. I don't have multiple aliases for interfaces like your
printer/scanner, nor hostnames that duplicate domain names like your
coyote, keeping things simpler. I do have a /root/hosts-2-antihosts
file, though, which is why there's that -[0-9]- wildcard.)

Cheers,
David.

Reply via email to