Saturday, 28 June 2014

How to bypass BT unreliable nameservers with your own fedora linux dhcp server

I was happily browsing via my BT Homehub broadband connection when for some reason sourceforge.net failed to be resolved in DNS.

I checked with
dig sourceforge.net
and sure enough no answer from nameserver.
The default nameserver was 192.168.1.254 which is my BT Homehub router.
Assuming this then delegated to BT nameservers  dynamically supplied when the broadband connection was made, I looked up these nameservers from the homehub status pages (http://192.168.1.254) and tried them directly and still no answer.

However google nameservers were able to provide an answer.
dig @8.8.8.8 sourceforge.net

I tried rebooting the router and got different nameservers but still not fully functional for all domains.

Google was still working for most sites (but not for some bt community forums which google was showing might have a solution for me).

Sadly the nameservers are not configurable in the BT HomeHub.

I could configure my PC to not use the automatic DHCP supplied DNS servers for this session by editing /etc/resolv.conf to use google nameservers:-

# Generated by NetworkManager
domain cycom.co.uk
search cycom.co.uk cycom.co.uk.
nameserver 8.8.8.8
nameserver 8.8.4.4



(note microsoft users can do something similar by editing the IPV4 and IPV6 properties of  their network connection as explained in my next blog post).

but /etc/resolv.conf was going to be overwritten by network manager next time I connect and I really wanted to continue to use DHCP for everything including from my android phones so with the temporary fix in place I started to configure a dhcp server on my local fedora linux server.

You do need a local linux server configured with a fixed (local network) ip on your home network (e.g. 192.168.1.72).

On this local server, I installed dhcpd with:-
yum install dhcp

Then I edit the config file /etc/dhcp/dhcp.conf to have this content:-

# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#

# option definitions common to all supported networks...
option domain-name "cycom.co.uk";
option domain-name-servers 8.8.8.8, 8.8.4.4;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.1.254;
option domain-search "cycom.co.uk";

default-lease-time 6000;
max-lease-time 72000;

# Use this to enable / disable dynamic dns updates globally.
#ddns-update-style none;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

subnet 192.168.1.0 netmask 255.255.255.0 {
   range 192.168.1.100 192.168.1.200;
}


and then enable and start the dhcpd service:-

systemctl enable dhcpd
systemctl start dhcpd

On the BT HomeHub router I disabled dhcp server leaving me with just the dhcp server on my linux server.

After testing with my android devices, I rebooted my linux laptop (this is the one where I had temporarily overridden the nameservers) and confirmed that the DHCP supplied values now matched google nameservers.

I can sleep much happier now knowing that my DNS is independent of the unreliable BT nameservice.




No comments:

Post a Comment