The change via web page is preferable. However, if you are running without the web interface being installed, you can also change them manually in
/etc/pihole/setupVars.conf
/etc/dnsmasq.d/01-pihole.conf
Change them in both files and run
sudo service dnsmasq restart
afterwards.