We have moved to a new Sailfish OS Forum. Please start new discussions there.
28

Add the ability to change DNS settings for 3G

asked 2014-01-21 10:42:52 +0200

c.la gravatar image

updated 2014-01-21 12:22:08 +0200

I found out that my 3g provider has the "DNS catch all" so that when a DNS query returns no result it redirects the connection to its own search engine sugesting similar websites. for example if in the browser I digit dnas.fi (or any other non existant domain) I don't get the error of invalid domain but a search page.

The only way to avoid this is to change the DNS settings so that I opt out of this "service" and I get to have the RFC way of working DNS.

Please add the capability to edit DNS for an APN.

EDIT: the provider in its help pages indicates to configure on the device other DNS servers to opt-out of this feature, it's not a my implementation of a workaround. The provider itself offers alternative DNS servers that have the standard RFC behavior. That option would be useful to use third party DNS as well.

edit retag flag offensive close delete

Comments

2

My mobile carrier's DNS is particularly slow so being able to use another DNS provider would be useful.

aegis ( 2014-01-21 10:51:07 +0200 )edit
3

It is unethical not to return a correct response to a DNS request and hijack the users browser. Richard

richardski ( 2014-01-21 11:09:09 +0200 )edit

@richardski I agree, but how can i fight that vs a big telecom corporation? :( And, by the way, many landline ISPs (ADSL/fiber) are implementing this, offering their own alternative DNS servers to opt out. ISPs get revenue because of that and inexperienced users see this as "service".

c.la ( 2014-01-21 12:17:17 +0200 )edit

1 Answer

Sort by » oldest newest most voted
10

answered 2015-04-11 04:35:32 +0200

Louis gravatar image

updated 2020-05-03 21:57:11 +0200

3th of May 2020: Updated to work regardless of connman version installed and tested on Jolla C running SFOS 3.3.0.16.

This is just a work-around to set custom nameservers (DNS) for a desired network interface. It'll be permanent and work across reboots. Use at your own risk and be sure to have charged your Jolla phone before setting this up. In my case <10% battery life was used.

Here's how to configure custom nameservers for a particular network interface. You need to have dev mode enabled and 30 minutes available (to be safe) for your Jolla phone to compile some stuff. It's recommended to SSH to your Jolla phone from a computer for easier management.

1. Get source and build connman to get the missing connmanctl.

devel-su
pkcon install gcc gcc-c++ make automake autoconf libtool glib2-devel dbus-devel iptables-devel gnutls-devel readline-devel 
cd /home/nemo/Downloads
CONNMAN_VER=$(connmand -v|cut -d'+' -f1)
curl -O https://git.kernel.org/pub/scm/network/connman/connman.git/snapshot/connman-${CONNMAN_VER}.tar.gz
tar xf connman-${CONNMAN_VER}.tar.gz
cd connman-${CONNMAN_VER}
./bootstrap
./configure
make
cp client/connmanctl /usr/local/bin/

2. Remove dependencies and files not needed after build (still as root)

pkcon remove kernel-headers glibc-headers binutils gcc gcc-c++ make automake autoconf  glibc-devel pcre-devel glib2-devel gnutls-devel libgcrypt-devel libgpg-error-devel libtasn1-devel zlib-devel ncurses-devel readline-devel iptables-devel dbus-devel
rm -rf /home/nemo/Downloads/connman-*

3. Configure a network interface to use specific nameservers (DNS) (Still as root)

List available networks

[root@jolla-hostname ~]# connmanctl services
*ssid_name                wifi_[NUMBERS]_managed_psk
*   provider_name           cellular_[NUMBERS]_context1

Configure name servers for your desired network interface. Replace 8.8.x.x with whatever you like.

[root@jolla-hostname ~]# connmanctl config cellular_[NUMBERS]_context1 --nameservers 8.8.8.8 8.8.4.4

If you're currently connected to the edited network, disconnect and connect to it again for the changes to take effect.


Additional options:

See currently custom configured nameservers (output empty if none set)

[root@jolla-hostname ~]# grep "Nameservers" /var/lib/connman/cellular_[NUMBERS]_context1/setttings

Unset custom nameserver settings

connmanctl config cellular_[NUMBERS]_context1 --nameservers

Uninstall custom compiled connmanctl:

rm /usr/local/bin/connmanctl
edit flag offensive delete publish link more

Comments

1

To make this a bit easier. I compiled the connmanctl binary and uploaded it to dropbox. Cooy this to /usr/locak/bin as instructed above, to use.

https://www.dropbox.com/s/5j70gwxo028gkp4/connmanctl?dl=0

Dont forget to chmod 755 on the copied file ;)

Nieldk ( 2015-04-11 08:49:23 +0200 )edit

Thanks @Nieldk - but I did notice in your comment; '/usr/locak/ - locak? , I know what you mean, others may not, just saying :)

Spam Hunter ( 2015-04-11 14:31:06 +0200 )edit

@Markkyboy yes you are right. Should be /usr/local/bin Sadly I cant edit comment now....

Nieldk ( 2015-04-11 17:38:12 +0200 )edit

@Louis, I consider this a quite beautiful answer to this question. My first approach would be a local dnscache daemon and a 'locked' resolve.conf, but then it may be easier to write some iptables rules to redirect port 53 traffic. But I favor your solution.

Maus ( 2015-04-11 21:50:22 +0200 )edit
Login/Signup to Answer

Question tools

Follow
4 followers

Stats

Asked: 2014-01-21 10:42:52 +0200

Seen: 1,825 times

Last updated: May 03 '20