DNS Redirection

quick question, hopefully someone has a quick answer!

The softap implementation starts a dns_redirector service. What redirections does it do? How can this be configured?

Usecase: I’d like to redirect all requests to the photon ip, or, I want to redirect a specific domain or hostname.

Yes, you’re in luck! We added this internally for 0.4.6 - public announcement pending CLI support, which will make it easier to manage the DNS redirect entries.

If you want to go the manual route, here’s the format:

DNS redirect entries are stored in a 128 byte block at location 1890 in the DCT region.

The domain format is zero or more blocks like this:

[length of name (as binary)
name]+
null character

e.g. “www.particle.io” is encoded as 17 bytes:
0x03 “www” 0x08 “particle” 0x02 “io” 0x00

The end of the list is denoted by an extra null byte (0x00).

Here’s an example with 2 FQDNs:

0x03 "www" 0x08 "particle" 0x02 "io" 0x00
0x05 "setup" 0x08 "particle" 0x03 "com" 0x00
0x00

To write a block like this to the DCT region, it’s simplest to first build the file, and then use DFU util to transfer:

echo -e -n "/x03www/x08particle/x02io/x00/x00" > dns_redirect
dfu-util -d 2b04:d006 -a 1 -s 1890 -D dns_redirect

The device does already recognise some DNSs that were added by broadcom, e.g. google.com.

I hope that helps! :smile:

2 Likes

that’s brilliant, thanks @mdma
Are the broadcom entries contained in the same DCT block, ie will they be overwritten by writing to it?
If not, do you know what the full list is or where to find it?

The broadcom entries are separate, so not overwritten, although tbh I wouldn’t depend upon them being around forever - they seem quite arbitrary. You can probably find them by looking at system-part2.bin and searching for “google”

Understood.

There’s a static array in dns_redirect.c which in WICED 3.1.2 contains these entries:
"\x0Asecuredemo\x05wiced\x08broadcom\x03com" "\x05apple\x03com" "\x03www\x05apple\x03com" "\x06google\x03com" "\x03www\x06google\x03com" "\x04bing\x03com" "\x03www\x04bing\x03com" "\x08facebook\x03com" "\x03www\x08facebook\x03com" "\x08broadcom\x03com" "\x03www\x08broadcom\x03com" "\x05wiced\x03com" "\x03www\x05wiced\x03com" "\x08clients3\x06google\x03com"