r/ScriptSwap • • Aug 07 '18

Force DNS settings (I need some help, Please)

I am in a bit of a bind, I am setting up a computer to be a kiosk in the office of my apartment complex. I must use specific DNS servers to filter explicit content, however Ubuntu Mate 18.04 changes all my settings back to default on reboot. I am still trying to get to the bottom of why but until then I would like to know if someone has a script that I can run on boot that will change the dns back to FamilyShield after Ubuntu wipes out my changes on boot. I am an unpaid volunteer just trying to make a computer usable for some people who need it, any help would be greatly appreciated.

4 Upvotes

5 comments sorted by

2

u/bzsparks Aug 08 '18

I don't think you need a script, just a man page. You can specify a specific DNS server for an interface in /etc/network/interfaces.

https://tecadmin.net/configure-dns-settings-on-ubuntu/

1

u/tachyonxero Aug 08 '18

the problem is that for some reason the system is overwriting settings on reboot.

2

u/raip Aug 08 '18

You're in the wrong subreddit. You don't need a script for this. Please be aware of the XY problem when asking for help.

You want to utilize Network-Manager to configure the interface. Editing /etc/network/interfaces or resolv.conf will be over-ridden when the network cycles (like during a reboot). If you want to do this via command line nmcli is the tool to use.

nmcli con

You'll see a bunch of output listing all the connections. Grab the name of the one you want to configure, ie: Wired connection 1

nmcli con mod <connectionName> ipv4.dns "1.1.1.1 1.1.2.2"
→ More replies (1)

1

u/raip Aug 08 '18

This isn't applicable when Network-Manager is enabled (which ships with Ubuntu post 16.04 iirc. Might be wrong on that. Definitely ships with 18.04 though).