Can I add aliases?

Sometimes when I don't pay attention, I type drive.google.de instead of drive.google.com in my browser.

As drive.google.de doesn't lead anywhere, I wan't to save time correcting the URL and I want to be able to add that DNS name in pihole so that it always points to the current IP of drive.google.com

Since Google uses TLS encryption for their domains you wouldn't be able to substitute domains like that.

And on top of the TLS issue, even if we give you the right IP address for drive.google.com, your browser would try to connect to this server and ask for drive.google.de. The server wouldn't know how to serve this content.

1 Like

I managed anyway with below :wink:

pi@noads:~ $ cat /etc/dnsmasq.d/99-my-settings.conf
host-record=drive.google.com,172.217.17.78,2a00:1450:400e:804::200e
cname=drive.google.de,drive.google.com

pi@noads:~ $ sudo service pihole-FTL reload
pi@noads:~ $

pi@noads:~ $ host drive.google.de
drive.google.de is an alias for drive.google.com.
drive.google.com has address 172.217.17.78
drive.google.com has IPv6 address 2a00:1450:400e:804::200e
drive.google.com mail is handled by 30 alt3.gmr-smtp-in.l.google.com.
drive.google.com mail is handled by 20 alt2.gmr-smtp-in.l.google.com.
drive.google.com mail is handled by 5 gmr-smtp-in.l.google.com.
drive.google.com mail is handled by 40 alt4.gmr-smtp-in.l.google.com.
drive.google.com mail is handled by 10 alt1.gmr-smtp-in.l.google.com.

pi@noads:~ $ lynx https://drive.google.de
             Maak kennis met Google Drive: één plek voor al je bestanden
Eén account. Al het beste van Google.

Log in om door te gaan naar Google Drive

   [avatar_2x.png]
   Geef je e-mailadres op ____________________
   ____________________
   Volgende Mijn account zoeken

   Inloggen met een ander account Account maken

   Eén Google-account voor alles van Google
     * Over Google
     * Privacy
     * Voorwaarden
     * Help

   Taal wijzigen [<U+202A><U+202A>Nederlands<U+202C>_______________]

(Textfield "%s") Enter text. Use UP or DOWN arrows or tab to move off.
            Enter text into the field by typing on the keyboard
    Ctrl-U to delete all text in field, [Backspace] to delete a charact

This only works because Google is sending a 307 response and telling the browser to use a different FQDN. It's not a DNS solution, it's purely the web server accepting any domain name and having the client change. If you do this in a full browser you will see the URL changes.

pi@noads:~ $ cat /etc/dnsmasq.d/99-my-settings.conf
cname=drive.google.de,pi.hole

pi@noads:~ $ sudo service pihole-FTL reload
pi@noads:~ $

pi@noads:~ $ lynx http://drive.google.de
                                                       ● drive.google.de
   [ ]

   Open Source Ad Blocker Designed for Raspberry Pi
   pi.hole

   drive.google.de

   [ ]
   011

   drive.google.de_____ ____________________ (BUTTON)
   Friday 10:26 PM, September 06th. Pi-hole v4.3-0-g1d43c0a
   (noads.dehakkelaar.nl/10.0.0.2)

(Checkbox Field) Use right-arrow or <return> to toggle.
  Arrow keys: Up and Down to move.  Right to follow a link; Left to go b
 H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history

Right, run curl -I drive.google.de and curl -I https://drive.google.de and see that response codes coming from the server.

Edit: And use a browser client that most of our users would use. You're probably the only person other than I on this board that even know lynx exists.

1 Like

Yeah results depend on how the web server is configured ... I understand.

For the record:

pi@noads:~ $ curl -I http://drive.google.de
HTTP/1.1 301 Moved Permanently
[..]
Location: https://drive.google.de/
[..]

pi@noads:~ $ curl -I https://drive.google.de
HTTP/2 307
[..]
location: https://drive.google.com/
[..]

EDIT: Ps. I also suspect its user agent dependent like many web servers.

EDIT2: I removed some to make difference more clear to understand what happens.

One more addition why TLS is working for this instance:

pi@noads:~ $ echo | openssl s_client -connect drive.google.de:443 2>/dev/null | openssl x509 -text
[..]
        Subject: C = US, ST = California, L = Mountain View, O = Google LLC, CN = *.google.com
[..]
            X509v3 Subject Alternative Name:
                DNS:*.google.com, DNS:*.android.com, DNS:*.appengine.google.com, DNS:*.cloud.google.com, DNS:*.crowdsource.google.com, DNS:*.g.co, DNS:*.gcp.gvt2.com, DNS:*.gcpcdn.gvt1.com, DNS:*.ggpht.cn, DNS:*.gkecnapps.cn, DNS:*.google-analytics.com, DNS:*.google.ca, DNS:*.google.cl, DNS:*.google.co.in, DNS:*.google.co.jp, DNS:*.google.co.uk, DNS:*.google.com.ar, DNS:*.google.com.au, DNS:*.google.com.br, DNS:*.google.com.co, DNS:*.google.com.mx, DNS:*.google.com.tr, DNS:*.google.com.vn, DNS:*.google.de, DNS:*.google.es, DNS:*.google.fr, DNS:*.google.hu, DNS:*.google.it, DNS:*.google.nl, DNS:*.google.pl, DNS:*.google.pt, DNS:*.googleadapis.com, DNS:*.googleapis.cn, DNS:*.googlecnapps.cn, DNS:*.googlecommerce.com, DNS:*.googlevideo.com, DNS:*.gstatic.cn, DNS:*.gstatic.com, DNS:*.gstaticcnapps.cn, DNS:*.gvt1.com, DNS:*.gvt2.com, DNS:*.metric.gstatic.com, DNS:*.urchin.com, DNS:*.url.google.com, DNS:*.wear.gkecnapps.cn, DNS:*.youtube-nocookie.com, DNS:*.youtube.com, DNS:*.youtubeeducation.com, DNS:*.youtubekids.com, DNS:*.yt.be, DNS:*.ytimg.com, DNS:android.clients.google.com, DNS:android.com, DNS:developer.android.google.cn, DNS:developers.android.google.cn, DNS:g.co, DNS:ggpht.cn, DNS:gkecnapps.cn, DNS:goo.gl, DNS:google-analytics.com, DNS:google.com, DNS:googlecnapps.cn, DNS:googlecommerce.com, DNS:source.android.google.cn, DNS:urchin.com, DNS:www.goo.gl, DNS:youtu.be, DNS:youtube.com, DNS:youtubeeducation.com, DNS:youtubekids.com, DNS:yt.be
[..]
1 Like

Ah, nice! What's stopping them from SAN: DNS: * ? :slight_smile:

I want one very much ... trusted :wink:

1 Like

Become your own CA, write your own browser and include said CA as default trust store.

1 Like

I want browser trusted :smiley:

EDIT:m missed this bit:

lol

I added those two lines to a new file "/etc/dnsmasq.d/05-aliases.conf"

host-record=drive.google.com,172.217.21.238,2a00:1450:4001:821::200e
cname=drive.google.de,drive.google.com,pi.hole

But when I execute sudo service dnsmasq restart, I get the following error:

Sep 07 19:11:41 raspberrypi dnsmasq[13667]: dnsmasq: bad TTL at line 2 of /etc/dnsmasq.d/05-aliases.conf
Sep 07 19:11:41 raspberrypi dnsmasq[13667]: bad TTL at line 2 of /etc/dnsmasq.d/05-aliases.conf
Sep 07 19:11:41 raspberrypi dnsmasq[13667]: FAILED to start up
Sep 07 19:11:41 raspberrypi systemd[1]: dnsmasq.service: Control process exited, code=exited status=1
Sep 07 19:11:41 raspberrypi systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.

Dont start up dnsmasq!
dnsmasq is embedded in the pihole-FTL binary:

pi@noads:~ $ which pihole-FTL
/usr/bin/pihole-FTL

Until not that long ago, Pi-hole depended on the dnsmasq binary but not anymore.
Try:

sudo service pihole-FTL restart

Or less intrusive:

sudo service pihole-FTL reload

Or:

pihole restartdns

1 Like

This doesnt work.
Your telling pihole-FTL(dnsmasq) that drive.google.de and drive.google.com are an alias for pi.hole

See my example:

EDIT: had to lookup but cname only allows one alias and one target name per line:

pi@noads:~ $ man dnsmasq
[..]
       --cname=<cname>,<target>[,<TTL>]
              Return  a  CNAME  record which indicates that <cname> is
              really <target>. There are  significant  limitations  on
              the target; it must be a DNS name which is known to dns‐
              masq from /etc/hosts (or additional hosts  files),  from
              DHCP, from --interface-name or from another --cname.  If
              the target does not satisfy  this  criteria,  the  whole
              cname  is  ignored.  The cname must be unique, but it is
              permissable to have more than one cname pointing to  the
              same target.

              If  the time-to-live is given, it overrides the default,
              which is zero or the value of -local-ttl. The value is a
              positive integer and gives the time-to-live in seconds.

Yes, that works, thanks!

But it didn't work after sudo service pihole-FTL restart so I tried sudo service dnsmasq restart and then it worked.

Thanks a lot!

1 Like

Upgrade !!! :smiley:
What version do you have running now ?

pihole -v

To upgrade:

pihole -up

But do this when you have plenty of time at hand because things might break!

EDIT: and use Teleporter to export a backup from the settings before the upgrade:

http://pi.hole/admin/settings.php?tab=teleporter

In the end I got it working.

But how would I define multiple aliases for a domain or multiple aliases for different domains?

I tried this for 2 domains but restarting dnsmasq results in an error

host-record=drive.google.com,172.217.21.238
cname=drive.google.de,drive.google.com
host-record=keep.google.com,172.217.16.142
cname=keep.google.de,drive.google.com

Looks like pihole-FTL(dnsmasq) doesnt like you creating an A record for keep.google.com as well as it being an alias for a target(domain).
If you read carefully, only the target domain needs to be a known domain for pihole-FTL:

pi@noads:~ $ man dnsmasq
[..]
              There are  significant  limitations  on
              the target; it must be a DNS name which is known to dns‐
              masq from /etc/hosts (or additional hosts  files),  from
              DHCP, from --interface-name or from another --cname.  If
              the target does not satisfy  this  criteria,  the  whole
              cname  is  ignored.  The cname must be unique, but it is
              permissable to have more than one cname pointing to  the
              same target.

If you havent figured it out already, try below:

pi@noads:~ $ cat /etc/dnsmasq.d/99-my-settings.conf
host-record=drive.google.com,172.217.21.238
cname=drive.google.de,drive.google.com
cname=keep.google.de,drive.google.com

pi@noads:~ $ sudo service pihole-FTL reload
pi@noads:~ $

pi@noads:~ $ host drive.google.de
drive.google.de is an alias for drive.google.com.
drive.google.com has address 172.217.21.238
drive.google.com has IPv6 address 2a00:1450:400e:807::200e
[..]

pi@noads:~ $ host keep.google.de
keep.google.de is an alias for drive.google.com.
drive.google.com has address 172.217.21.238
drive.google.com has IPv6 address 2a00:1450:400e:807::200e
[..]