[Solved] TCP/IP DNS file

Technical issues/questions of an intermediate or advanced nature.
User avatar
Ed_P
Contributor
Contributor
Posts: 3409
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

[Solved] TCP/IP DNS file

Post#1 by Ed_P » 03 May 2017, 22:13

On Windows there is the hosts file which allows one to direct host names to specific IP addresses, such as:

127.0.0.1 ad.doubleclick.net
127.0.0.1 advertizing.com

Is there a similar file/function, in Porteus?
Ed

Evan
Warlord
Warlord
Posts: 519
Joined: 11 Apr 2016, 09:00
Distribution: Anything Cinnamon
Location: London

Re: TCP/IP DNS file

Post#2 by Evan » 03 May 2017, 23:43

sudo gedit /etc/hosts

Examples:

0.0.0.0 www.nastyadserver.ads
0.0.0.0 fr.weliketospyonyou.nowhere
0.0.0.0 m.t.whatisthis.huh
0.0.0.0 ad.server.notagain

https://delightlylinux.wordpress.com/20 ... osts-file/

Is the above info any good?

User avatar
Ed_P
Contributor
Contributor
Posts: 3409
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: TCP/IP DNS file

Post#3 by Ed_P » 04 May 2017, 03:41

Evan wrote:Is the above info any good?
Perfect Evan. :Yahoo!: Absolutely perfect. :good: :beer:

:friends:
Ed

Bogomips
Full of knowledge
Full of knowledge
Posts: 2563
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: TCP/IP DNS file

Post#4 by Bogomips » 06 May 2017, 01:55

Great Guns! Being plagued by these parasites. Had to enable javascript on a site, and as soon as finished stopped all scripts in tab, I thought. Closed tab, then went on to view embedded youtube video with html player, playback jerky, suspected script, but cpu at around 40%, Maybe yt overburdened, tried couple more and no better, but then all of a sudden script went ballistic at 100% cpu. After best part of a minute of frozen computer had to kill browser. :twisted:

The script here http://www.putorius.net/2012/01/block-u ... ts-on.html looks like a must, which will have to put in guiexec to alleviate some of the script misery.
It could be that a different domain name or even a direct IP address is used for the connection. Some ads are sneaky, so double check. An entry in /etc/hosts might exist for y.lottaspam.fr.m, but the ad could be connecting directly to its server using an IP address. In this case, /etc/hosts will not help.
In this case have to rely on extensions which block URLs, like SilentBlock, which uses regular expression matching. And using in conjunction with HTTP Request Logger add-on could provide a clearer picture:

Code: Select all

guest@porteus:~$ grep '[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+' Desktop/http-request-log.txt  | tail      
(none) GET https://www.google.com/gen_204?atyp=i&zx=1493984138491&ei=8GEMWaPCKsvWmwGv9pqQAw&ogf=.40.36.36.40.36.36.&ogrp=&ogv=1493707922.0&ogd=&ogc=DEU&ogl=en-GB&oggv=es_plusone_gc_20170309.0_p0&oge=5&ogex=40400&ogp=23&ogsr=1&ogus=1
(none) GET https://www.google.com/gen_204?atyp=i&zx=1493984141666&ei=8GEMWaPCKsvWmwGv9pqQAw&ogf=.40.36.36.40.36.36.&ogrp=&ogv=1493707922.0&ogd=&ogc=DEU&ogl=en-GB&oggv=es_plusone_gc_20170309.0_p0&oge=9&ogex=40400&ogp=23&ogsr=1&ogus=1&ogad=l.o
(none) GET https://openload.co/stream/l7z-vY25o5Q~1494071353~142.4.0.0~di0bW7db
(none) GET https://openload.co/stream/vBwcg832hng~1494075333~142.4.0.0~ld7I7YAc?mime=true
(none) GET https://openload.co/stream/vBwcg832hng~1494076014~142.4.0.0~g0wdOIov
(none) GET https://openload.co/stream/Je5vXXZ7aes~1494080762~142.4.0.0~IVsq40Sz
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

User avatar
Ed_P
Contributor
Contributor
Posts: 3409
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: [Solved] TCP/IP DNS file

Post#5 by Ed_P » 06 May 2017, 05:07

^

Code: Select all

root@porteus:/home/guest# grep '[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+' Desktop/http-request-log.txt  | tail 
grep: Desktop/http-request-log.txt: No such file or directory
root@porteus:/home/guest# grep '[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+' Cinnamon/http-request-log.txt  | tail 
grep: Cinnamon/http-request-log.txt: No such file or directory
Why don't you try the hosts file Evan suggested?


-edit-

Oh! Just visited the link you posted. Interesting
Ed

Evan
Warlord
Warlord
Posts: 519
Joined: 11 Apr 2016, 09:00
Distribution: Anything Cinnamon
Location: London

Re: [Solved] TCP/IP DNS file

Post#6 by Evan » 06 May 2017, 08:10

I think it was on Puppylinux forum that i read something ages ago that said if you start adding a large block lists at system level then it starts adding latency to all network connections where it keeps scanning the blocklist for all connections rather than just the ones your web browser uses.......

The web browser add-on uBlock Origin was recommended as it scored the best on all test results and added very little latency and was lower on resources , the wiki says the same.

https://addons.mozilla.org/en-GB/firefo ... ck-origin/
https://chrome.google.com/webstore/deta ... phjbkeiagm
UBlock Origin
Technology websites and user reviews for uBlock have regarded the extension as less resource intensive in comparison with extensions that provide similar feature sets such as Adblock Plus.A benchmark test, conducted in August 2015 with ten blocking extensions, showed uBlock Origin as the most resource efficient among extensions tested.

uBlock surveys what style resources are required for an individual web page rather than reliance on a universal style sheet. The extension takes a snapshot of the filters the user has enabled. This contributes to accelerated browser start-up speed when compared to retrieving filters from cache every time.

Bogomips
Full of knowledge
Full of knowledge
Posts: 2563
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: [Solved] TCP/IP DNS file

Post#7 by Bogomips » 06 May 2017, 17:06

Ed_P wrote:^

Code: Select all

root@porteus:/home/guest# grep '[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+' Desktop/http-request-log.txt  | tail 
grep: Desktop/http-request-log.txt: No such file or directory
root@porteus:/home/guest# grep '[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+' Cinnamon/http-request-log.txt  | tail 
grep: Cinnamon/http-request-log.txt: No such file or directory
https://shiftlock.wordpress.com/2011/07 ... a-firefox/ ;)
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

User avatar
Ed_P
Contributor
Contributor
Posts: 3409
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: [Solved] TCP/IP DNS file

Post#8 by Ed_P » 06 May 2017, 20:45

Interesting. :)
Ed

Bogomips
Full of knowledge
Full of knowledge
Posts: 2563
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: [Solved] TCP/IP DNS file

Post#9 by Bogomips » 07 May 2017, 17:34

Offering a script: hoisted.sh ;)

Code: Select all

#!/bin/bash
# if you need to add something to your hosts file you now want to add it to .etc/suphosts
# Uses/Creates a Directory .etc for hosts.txt file and for suphosts
hoisted()
{
    [[ -d .etc ]] || mkdir .etc || return 1
    wget -O .etc/hosts  http://winhelp2002.mvps.org/hosts.txt
    sed -i '/^127.0.0.1/a\
# Linux box.\
127.0.0.1       porteus.example.net porteus'  .etc/hosts
    [[ -f .etc/suphosts ]] && cat .etc/suphosts >> .etc/hosts
    sudo ln -sf  ~/.etc/hosts   /etc/hosts
}
hoisted $*
 
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

Evan
Warlord
Warlord
Posts: 519
Joined: 11 Apr 2016, 09:00
Distribution: Anything Cinnamon
Location: London

Re: [Solved] TCP/IP DNS file

Post#10 by Evan » 07 May 2017, 23:09

I'm starting to feel like the new Fullmoonremix :roll: :)

https://www.bleepingcomputer.com/tutori ... -explained
NOTE: It is important to note that there have been complaints of system slowdowns when using a large hosts file. This is usually fixed by turning off and disabling the DNS Client in your Services control panel under Administrative Tools. The DNS client caches previous DNS requests in memory to supposedly speed this process up, but it also reads the entire HOSTS file into that cache as well which can cause a slowdown. This service is unnecessary and can be disabled.
If you must use a large host file instead of the Ublock Origin browser add-on then you'll find a couple of other url's for host block list in the link above.

hpguru's HOSTS File can be found here: http://www.hosts-file.net/

The MVPS Host File can be found at: http://www.mvps.org.

Hosts File Project can be found here : http://remember.mine.nu/
eDexter - When you block ads on web sites using a HOSTS file, there tends to be empty boxes on the web site you are visiting where the ad would normally have appeared. If this bothers you, you can use the program eDexter to fill in the image with one on your local machine such as a clear image or any other one for that matter. This removes the empty boxes and is quick because the replacement image is loaded off of your hard drive.

Hostess - Hostess is an application that is used to maintain and organize your HOSTS file. This program will read your HOSTS file and organize the entries contained in it into a database. You can then use this database to scan for duplicates and to manage the entries. It is a program that is definitely worth checking out if you plan on using the HOSTS file extensively.
test results for Ublock origin being lower on Cpu and Ram

https://github.com/gorhill/uBlock

It also includes the above host block list file in this thread and many more.

User avatar
Ed_P
Contributor
Contributor
Posts: 3409
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: [Solved] TCP/IP DNS file

Post#11 by Ed_P » 07 May 2017, 23:20

hmmmm Bogomips

Maybe

Code: Select all

#!/bin/bash
# http://forum.porteus.org/viewtopic.php?f=140&t=6908&p=55064#p55061
# if you need to add something to your hosts file you now want to add it to .etc/suphosts
# Uses/Creates a Directory .etc for hosts.txt file and for suphosts
hoisted()
{
    [[ -d .etc ]] || mkdir .etc || return 1
    wget -O .etc/hosts  http://winhelp2002.mvps.org/hosts.txt
    sed -i '/^127.0.0.1/a\
# Linux box.\
127.0.0.1       $1  $2'  .etc/hosts
    [[ -f .etc/suphosts ]] && cat .etc/suphosts >> .etc/hosts
    sudo ln -sf  ~/.etc/hosts   /etc/hosts
}
hoisted $*
 
would allow for

Code: Select all

hoisted.sh   epiclol.com	"# FB pop under ad"
Evan wrote:
it also reads the entire HOSTS file into that cache as well which can cause a slowdown.
Wouldn't that be only for the 1st time with all subsequent reads from the HOSTS file in the cache?
Ed

Evan
Warlord
Warlord
Posts: 519
Joined: 11 Apr 2016, 09:00
Distribution: Anything Cinnamon
Location: London

Re: [Solved] TCP/IP DNS file

Post#12 by Evan » 08 May 2017, 05:14

Ed_P wrote:Wouldn't that be only for the 1st time with all subsequent reads from the HOSTS file in the cache?
I dunno dude , i'm just the messenger. :D :friends:

Maybe i have this wrong but all i can remember from a couple of years ago was the least preferred method is to use a fixed host file because that means every network connection that has nothing to do with web browsing are also being checked which is a complete waste of time and resources , 1000's of bittorent connections for example.

The preferred method was to only load a block list when the web browser is active. :unknown:

Bogomips
Full of knowledge
Full of knowledge
Posts: 2563
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: [Solved] TCP/IP DNS file

Post#13 by Bogomips » 08 May 2017, 19:41

Evan wrote:The preferred method was to only load a block list when the web browser is active. :unknown:
Okay, battening down the hatches:
  • Revised more secure hoisted.sh

    Code: Select all

    #!/bin/bash
    # if you need to add something to your hosts file you now want to add it to .etc/suphosts
    # Uses/Creates a Directory .etc for hosts.txt file and for suphosts
    hoisted()
    # Restore original hosts: sudo cp /etc/hosts.bak /etc/hosts
    {
        [[ -e /etc/hosts.bak ]] || cp /etc/hosts /etc/hosts.bak || return 2
        [[ -d .etc ]] || mkdir .etc || return 1
        wget -O .etc/hosts  http://winhelp2002.mvps.org/hosts.txt
        sed -i '/^127.0.0.1/a\
    # Linux box.\
    127.0.0.1       porteus.example.net porteus'  .etc/hosts
        [[ -f .etc/suphosts ]] && cat .etc/suphosts >> .etc/hosts
        sudo  cp  .etc/hosts   /etc/hosts
        ls -lh /etc/hosts{,.bak}
        echo -n "Entries: "; wc -l /etc/hosts
    }
    hoisted $* 
  • Ed_P wrote:would allow for

    Code: Select all

    hoisted.sh   epiclol.com	"# FB pop under ad"
    In this manner:
    • Code: Select all

      guest@porteus:~$ #!/bin/bash
      guest@porteus:~$ # if you need to add something to your hosts file you now want to add it to .etc/suphosts
      guest@porteus:~$ # Uses/Creates a Directory .etc for hosts.txt file and for suphosts
      guest@porteus:~$ hoisted()
      > # Restore original hosts: sudo cp /etc/hosts.bak /etc/hosts
      > {
      >     [[ -e /etc/hosts.bak ]] || cp /etc/hosts /etc/hosts.bak || return 2
      >     [[ -d .etc ]] || mkdir .etc || return 1
      >     wget -O .etc/hosts  http://winhelp2002.mvps.org/hosts.txt
      >     sed -i '/^127.0.0.1/a\
      > # Linux box.\
      > 127.0.0.1       porteus.example.net porteus'  .etc/hosts
      >     [[ -f .etc/suphosts ]] && cat .etc/suphosts >> .etc/hosts
      >     sudo  cp  .etc/hosts   /etc/hosts
      > }
      guest@porteus:~$ hoisted $*
      --2017-05-08 20:50:09--  http://winhelp2002.mvps.org/hosts.txt
      Resolving winhelp2002.mvps.org... 216.155.126.40
      Connecting to winhelp2002.mvps.org|216.155.126.40|:80... connected.
      HTTP request sent, awaiting response... 200 OK
      Length: 498107 (486K) [text/plain]
      Saving to: ‘.etc/hosts’
      
      .etc/hosts            100%[=========================>] 486.43K   337KB/s    in 1.4s
      
      2017-05-08 20:50:11 (337 KB/s) - ‘.etc/hosts’ saved [498107/498107]
      
      guest@porteus:~$ ls -lh /etc/hosts{,.bak}
      -rw-r--r-- 1 guest users 487K May  8 20:50 /etc/hosts
      -rw-r--r-- 1 guest users  786 May  8 20:50 /etc/hosts.bak
      
      guest@porteus:~$ tail -n3 /etc/hosts
      0.0.0.0 www.winadiscount.com #[Dr.Web.Adware.Xbarre]
      0.0.0.0 www.winaproduct.com
      # [end of entries generated by MVPS HOSTS]
      
    • :good: Already expunges google-analytics parasite. Just prior to this responsible for bringing down system. Script froze browser at 100% cpu and everything else. Killed browser, but upon restart managed to bring down system. :evil:

      Code: Select all

      guest@porteus:~$ grep google-analytics .etc/hosts 
      0.0.0.0 google-analytics.com
      0.0.0.0 ssl.google-analytics.com
      0.0.0.0 www.google-analytics.com #[affects Google Trends]
       
    • Add Supplement

      Code: Select all

      guest@porteus:~$ echo "0.0.0.0 epiclol.com # FB pop under ad" >> .etc/suphosts
      guest@porteus:~$ cat .etc/suphosts
      0.0.0.0 epiclol.com # FB pop under ad
      guest@porteus:~$ hoisted
      --2017-05-08 21:15:58--  http://winhelp2002.mvps.org/hosts.txt
      Resolving winhelp2002.mvps.org... 216.155.126.40
      Connecting to winhelp2002.mvps.org|216.155.126.40|:80... connected.
      HTTP request sent, awaiting response... 200 OK
      Length: 498107 (486K) [text/plain]
      Saving to: ‘.etc/hosts’
      
      .etc/hosts            100%[=========================>] 486.43K   360KB/s    in 1.3s
      
      2017-05-08 21:16:00 (360 KB/s) - ‘.etc/hosts’ saved [498107/498107]
      
      guest@porteus:~$ ls -lh /etc/hosts{,.bak}
      -rw-r--r-- 1 guest users 487K May  8 21:16 /etc/hosts
      -rw-r--r-- 1 guest users  786 May  8 20:50 /etc/hosts.bak
      
      guest@porteus:~$ tail -n3 /etc/hosts
      0.0.0.0 www.winaproduct.com
      # [end of entries generated by MVPS HOSTS]
      0.0.0.0 epiclol.com # FB pop under ad
      
  • Expanded hosts file is some 15000 lines which hardly takes any time to traverse these days, and all hardly takes up any memory relatively speaking, just under half a MiB:

    Code: Select all

    guest@porteus:~$ wc -l /etc/hosts
    15007 /etc/hosts
    
Last edited by Bogomips on 09 May 2017, 12:28, edited 1 time in total.
Reason: Entry Stats
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

User avatar
Ed_P
Contributor
Contributor
Posts: 3409
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: [Solved] TCP/IP DNS file

Post#14 by Ed_P » 08 May 2017, 23:34

Bogomips wrote: [*]Add Supplement

Code: Select all

guest@porteus:~$ echo "0.0.0.0 epiclol.com # FB pop under ad" >> .etc/suphosts
guest@porteus:~$ cat .etc/suphosts
0.0.0.0 epiclol.com # FB pop under ad
guest@porteus:~$ hoisted
So code can't be added to hoisted such that if a non-blank $1 is present it can:

Code: Select all

echo "127.0.0.1 $1 $2 $3 $4 $5 $6 $7 $8 $9" >> .etc/suphosts
cat .etc/suphosts
so a user in a single step can use:

Code: Select all

hoisted.sh epiclol.com # FB pop under ad
Bummer. :(

:D


And while we are talking about code, how do I get this code

Code: Select all

root@porteus:/home/guest# ls -lght /tmp/mod | awk '{print $4,$5,$6,$7,$8}'
which produces:

Code: Select all

120 May 8 18:13 var/
160 May 8 15:48 etc/
60 May 8 15:47 usr/
60 May 8 11:46 home/
to produce:

Code: Select all

120 May 8 18:13 var/
160 May 8 15:48 etc/
 60 May 8 15:47 usr/
 60 May 8 11:46 home/
Ed

Bogomips
Full of knowledge
Full of knowledge
Posts: 2563
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: [Solved] TCP/IP DNS file

Post#15 by Bogomips » 09 May 2017, 01:36

Ed_P wrote:
Bogomips wrote: So code can't be added to hoisted such that if a non-blank $1 is present it can:

Code: Select all

echo "127.0.0.1 $1 $2 $3 $4 $5 $6 $7 $8 $9" >> .etc/suphosts
cat .etc/suphosts
KISS
Ed_P wrote:so a user in a single step can use:

Code: Select all

hoisted.sh epiclol.com # FB pop under ad
Bummer. :(
DIY :twisted:
Ed_P wrote:And while we are talking about code, how do I get this code

Code: Select all

root@porteus:/home/guest# ls -lght /tmp/mod | awk '{print $4,$5,$6,$7,$8}'
which produces:

Code: Select all

120 May 8 18:13 var/
160 May 8 15:48 etc/
60 May 8 15:47 usr/
60 May 8 11:46 home/
to produce:

Code: Select all

120 May 8 18:13 var/
160 May 8 15:48 etc/
 60 May 8 15:47 usr/
 60 May 8 11:46 home/
Deserves topic in Programming section. 8)
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

Post Reply