View Single Post
Posts: 334 | Thanked: 616 times | Joined on Sep 2010
#7
I'm correcting myself again. Try hosts.txt (all # on the same line as IP):

Code:
127.0.0.1 im.not.malicious
112.112.112.112 im.malicious.com #localhost.localdomain #localhost #127.0.0.1
112.112.112.113 im.malicious.com localhost.localdomain localhost #127.0.0.1
111.111.111.114 colocalhosted #127.0.0.1 #colocalhosted
111.111.111.115 evil.com  #127.0.0.1
This resulted in a host-file:
Code:
127.0.0.1 localhost localhost.localdomain
::1 localhost6 localhost6.localdomain6
127.0.0.1 im.not.malicious
111.111.111.115 evil.com
The last line got through, only #127.0.0.1 was cut away.

The original hosts-file was:
Code:
127.0.0.1 localhost localhost.localdomain
::1 localhost6 localhost6.localdomain6
EDIT: Doing edits at the same time you answered. Previous was tested with original command (curl replaced with cat here):
Code:
cat hosts.txt | grep -v ^# | grep -v localhost | cut -d "#" -f 1 >> /etc/hosts.tmp && cat /etc/hosts.base /etc/hosts.tmp >> /etc/hosts && rm /etc/hosts.tmp && sed 's/^ *//; s/ *$//; /$/d' /etc/hosts

Last edited by Manatus; 2015-02-18 at 14:25.