You are not logged in.

#1 2010-12-16 01:59:09

Kilzool
Member
From: Ireland
Registered: 2010-08-04
Posts: 232

Is this correct please? /etc/hosts

#
# /etc/hosts: static lookup table for host names
#

#<ip-address>    <hostname.domain.org>    <hostname>
127.0.0.1                  mycomp.appsnet.net               localhost
::1                             mycomp.appsnet.net               localhost
192.168.1.101          mycomp.appsnet.net               mycomp
# End of file

Would this cause concern?

XFCE4
DHCP
Not using NetworkManger
Desktop

My static assigned ROUTER ip is 192.168.1.101
My registered domain is appsnet.net

Or is this better? What are the differences?

#
# /etc/hosts: static lookup table for host names
#

#<ip-address>    <hostname.domain.org>    <hostname>
127.0.0.1                      localhost.localdomain            localhost mycomp
::1                              localhost.localdomain            localhost mycomp
192.168.1.101           mycomp.appsnet.net            mycomp
# End of file

Offline

#2 2010-12-16 05:54:59

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: Is this correct please? /etc/hosts

127.0.0.1                      localhost.localdomain            localhost mycomp
::1                              localhost.localdomain            localhost mycomp

I don't have my own domain so I dunno about the 3rd line.

Last edited by graysky (2010-12-16 05:55:51)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#3 2010-12-16 17:52:06

masteryod
Member
Registered: 2010-05-19
Posts: 433

Re: Is this correct please? /etc/hosts

::1                             mycomp.appsnet.net               localhost

what is this for?

Last edited by masteryod (2010-12-16 17:54:17)

Offline

#4 2010-12-16 17:52:57

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,538

Re: Is this correct please? /etc/hosts

masteryod wrote:

::1                             mycomp.appsnet.net               localhost

what is this for?

ipv6

Offline

#5 2010-12-16 17:56:13

masteryod
Member
Registered: 2010-05-19
Posts: 433

Re: Is this correct please? /etc/hosts

Oh my gosh! That was the quickest answer ever! smile

Last edited by masteryod (2010-12-16 18:05:39)

Offline

#6 2010-12-16 19:02:20

Kilzool
Member
From: Ireland
Registered: 2010-08-04
Posts: 232

Re: Is this correct please? /etc/hosts

So, which example above (in my original post) is correct?  Are they both correct?  What is the best way to do this?

Offline

#7 2010-12-16 21:44:33

Leonid.I
Member
From: Aethyr
Registered: 2009-03-22
Posts: 999

Re: Is this correct please? /etc/hosts

The second looks almost fine. You could add another alias, though (https://bbs.archlinux.org/viewtopic.php?id=36909):

#
# /etc/hosts: static lookup table for host names
#

#<ip-address>   <hostname.domain.org>   <hostname>
127.0.0.1 arch.domain.edu localhost.localdomain localhost arch

xxx.xx.xxx.xx  arch.domain.edu  arch

# End of file

Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd

Offline

#8 2010-12-17 06:39:04

itman
Member
From: Switzerland
Registered: 2010-05-21
Posts: 124

Re: Is this correct please? /etc/hosts

A bit OT but usefull. While you're at it, why don't you add some additional stuff to your hosts-file to keep certain stuff at bay? Trackers and the like...

More info at:

Hosts-File from mvps
Ad-blocking hosts-file from yoyo.org

Merge those two files together and add it to your hosts file.

cheers

Offline

#9 2010-12-17 08:14:37

dyscoria
Member
Registered: 2008-01-10
Posts: 1,007

Re: Is this correct please? /etc/hosts

itman wrote:

A bit OT but usefull. While you're at it, why don't you add some additional stuff to your hosts-file to keep certain stuff at bay? Trackers and the like...

More info at:

Hosts-File from mvps
Ad-blocking hosts-file from yoyo.org

Merge those two files together and add it to your hosts file.

cheers

Here's a little script that does just that, based on one done by Wintervenom.

Copy existing /etc/hosts to /etc/hosts.local, and this script will merge the two blacklists, sort and delete duplicates, and output to /tmp/hosts. Change OUTPUTFILE to /etc/hosts if you want to run this script as root and not have to copy over the new hosts file.

#!/bin/bash
#
# Credit to Scott Garrett (Wintervenom) for the basis of this script
#

# set output file
OUTPUTFILE=/tmp/hosts

# make temporary directory
TMPDIR=/tmp/hostsupdatescript
mkdir -p "${TMPDIR}"

# download the mvps.org hosts file.
wget -c -O "${TMPDIR}/hosts.mvps" http://www.mvps.org/winhelp2002/hosts.txt
# find relevant lines without comments
grep ^127.0.0.1 "${TMPDIR}/hosts.mvps" > "${TMPDIR}/hosts.mvps.new1"
# 0.0.0.0 is nicer than constantly knocking on localhosts' door.
sed -e 's/127.0.0.1  /0.0.0.0 /g' "${TMPDIR}/hosts.mvps.new1" > "${TMPDIR}/hosts.mvps.new2"
# remove inline comments
cut -d' ' -f -2 "${TMPDIR}/hosts.mvps.new2" > "${TMPDIR}/hosts.mvps.new3"
# remove carriage returns
cat "${TMPDIR}/hosts.mvps.new3" | tr -d "\r" > "${TMPDIR}/hosts.mvps.final"

# download the pgl.yoyo.org hosts file
wget -c -O "${TMPDIR}/hosts.yoyo" "http://pgl.yoyo.org/as/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext"
# find relevant lines without comments
grep ^127.0.0.1 "${TMPDIR}/hosts.yoyo" > "${TMPDIR}/hosts.yoyo.new1"
# 0.0.0.0 is nicer than constantly knocking on localhosts' door.
sed -e 's/127.0.0.1/0.0.0.0/g' "${TMPDIR}/hosts.yoyo.new1" > "${TMPDIR}/hosts.yoyo.final"

# sort blocklist entries and remove duplicates
cat "${TMPDIR}/hosts.mvps.final" > "${TMPDIR}/hosts"
cat "${TMPDIR}/hosts.yoyo.final" >> "${TMPDIR}/hosts"
sort "${TMPDIR}/hosts" | uniq > "${TMPDIR}/hosts.final"

# write the user's hosts.local to head, then the blacklists
cat /etc/hosts.local > "${OUTPUTFILE}"
echo -e "\n# blocklist from mvps.org and pgl.yoyo.org" >> "${OUTPUTFILE}"
cat "${TMPDIR}/hosts.final" >> "${OUTPUTFILE}"

# delete temporary directory
rm -rf "${TMPDIR}

edit: typo

Last edited by dyscoria (2010-12-17 09:40:05)


flack 2.0.6: menu-driven BASH script to easily tag FLAC files (AUR)
knock-once 1.2: BASH script to easily create/send one-time sequences for knockd (forum/AUR)

Offline

#10 2010-12-17 09:43:09

jocheem67
Member
Registered: 2009-11-09
Posts: 243

Re: Is this correct please? /etc/hosts

That wintervenom's script is just beautiful..
I use an extended /etc/hosts to harden opera, and this merging seems fine. One question though:

the mvps one gets the 127.0.0.1 and the yoyo one gets the 0.0.0.0.

Someone knows the reason for that??

sed -e 's/127.0.0.1  /0.0.0.0 /g'

sed -e 's/127.0.0.1/0.0.0.0/g'

Maybe the reason? I'm no script-kiddie...

Last edited by jocheem67 (2010-12-17 09:54:42)

Offline

#11 2010-12-17 10:03:19

dyscoria
Member
Registered: 2008-01-10
Posts: 1,007

Re: Is this correct please? /etc/hosts

jocheem67 wrote:

That wintervenom's script is just beautiful..
I use an extended /etc/hosts to harden opera, and this merging seems fine. One question though:

the mvps one gets the 127.0.0.1 and the yoyo one gets the 0.0.0.0.

Someone knows the reason for that??

sed -e 's/127.0.0.1  /0.0.0.0 /g'

sed -e 's/127.0.0.1/0.0.0.0/g'

Maybe the reason? I'm no script-kiddie...

I changed the sed lines because the mvps blocklist has two spaces after 127.0.0.1 whereas the yoyo blocklist only has one space. If we leave it like it is, the duplicate lines (which are not actually duplicates because of the extra space) won't be removed.

Last edited by dyscoria (2010-12-17 10:03:51)


flack 2.0.6: menu-driven BASH script to easily tag FLAC files (AUR)
knock-once 1.2: BASH script to easily create/send one-time sequences for knockd (forum/AUR)

Offline

#12 2010-12-18 19:23:50

Leonid.I
Member
From: Aethyr
Registered: 2009-03-22
Posts: 999

Re: Is this correct please? /etc/hosts

itman wrote:

A bit OT but usefull. While you're at it, why don't you add some additional stuff to your hosts-file to keep certain stuff at bay? Trackers and the like...

More info at:

Hosts-File from mvps
Ad-blocking hosts-file from yoyo.org

Merge those two files together and add it to your hosts file.

cheers

That is the ugliest thing I saw... Dynamic blocking with a FF plugin is much more elegant IMHO. /etc/hosts is a system-wide config file and must not be touched whenever a user encounteres a malicious web site.


Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd

Offline

#13 2010-12-18 22:59:03

dyscoria
Member
Registered: 2008-01-10
Posts: 1,007

Re: Is this correct please? /etc/hosts

Leonid.I wrote:
itman wrote:

A bit OT but usefull. While you're at it, why don't you add some additional stuff to your hosts-file to keep certain stuff at bay? Trackers and the like...

More info at:

Hosts-File from mvps
Ad-blocking hosts-file from yoyo.org

Merge those two files together and add it to your hosts file.

cheers

That is the ugliest thing I saw... Dynamic blocking with a FF plugin is much more elegant IMHO. /etc/hosts is a system-wide config file and must not be touched whenever a user encounteres a malicious web site.

I actually think it's an effective way of blocking web sites. It is browser independent and free from false positives.

Granted Adblock Plus provides some further flexibility and functions, but I have a bias against third-party extensions tongue


flack 2.0.6: menu-driven BASH script to easily tag FLAC files (AUR)
knock-once 1.2: BASH script to easily create/send one-time sequences for knockd (forum/AUR)

Offline

#14 2010-12-24 20:31:25

itman
Member
From: Switzerland
Registered: 2010-05-21
Posts: 124

Re: Is this correct please? /etc/hosts

@Leonid.I that might be true for FF but what about the other browsers?

@dyscoria thanks for diggin out that script. Very usefull indeed.

hu - when running that script it throws:

./yoyo-mvps-hostsfile: Zeile 42: Dateiende beim Suchen nach `"' erreicht.
./yoyo-mvps-hostsfile: Zeile 44: Syntax Fehler: Unerwartetes Dateiende.

at me. The "/tmp/hosts" does get created and it seems ok to me....

cheers

Last edited by itman (2010-12-26 14:34:53)

Offline

Board footer

Powered by FluxBB