Monday, May 13, 2024

DNS SETUP on UBUNTU 24.04

In Kali / Debian, old Ubuntu, we used to edit /etc/network(ing)/interfaces where we could simply change ip to static, add default gateway, change net-mask and so. Then in /etc/resolve.conf we just added two nameservers from openDNS. That was it. 

In Ubuntu, the IfUP/ifDOWN network manager got changed by the Netplan service and our precious stuff is all over the place. I recently worked a lot with non gui, ubuntu server, but just yesterday, I installed the latest 24.04 ubuntu as my main OS and it is again different. 

/etc/resolve.conf is maintained, but is a symlink, for apps that still use it. Same for stub-resolve.conf

So first of all, if we wanted to get our own DNS servers going, we kind of must disable DHCP as it provides DNS too. Static IP will be needed. However, as I started with a clean install of the Ubuntu, it just got set up all on it's own, no questions asked. I thought just like in ubuntu-server I can get my 00-netcfg.yaml modified and that is it. No !!!
We must create one, actually. 

nano /etc/netplan/01-netcfg.yaml
------------------------------------------------------------------

network:        
     version: 2                    # use of Netplan version 2
     renderer: networkd            # system service provided by systemd
     ethernets:                    # ethernet config
       enp0s3:                     # 'enp0s3' interface config
          addresses:               
            - 192.168.1.40/24      # IP address and subnet mask
          routes:                    
            - to: default          # gateway default   
            via: 192.168.1.254     #router ip
          nameservers:             # DNS
            addresses: [208.67.222.222,208.67.220.220]

------------------------------------------------------------------
save & exit

After applying this, still, my DNS was coming from DHCP. So I checked 50-cloud-init.yaml in the same folder. It had a "dhcp4: true" notation, that I turned false, but in the meantime we can read the beginning of the file, that a

nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg 

file should be created with this content:
------------------------------------------------------------------

network:
    ethernets:
        enp3s0:
            dhcp4: false
    version: 2

------------------------------------------------------------------
save&exit

netplan apply

Warning / Warning / Warning - about your config files being too open. So simply : '/etc/netplan/chmod 600 *'
so all files will be read and write for root, and no-one else.

NO DHCP / OpenDNS
All is nice and cute, but your router might still be set up to use 1.1.1.1 or 8.8.8.8 for name resolving. To assure more of your anonymity, you should change your router settings too, just in case other devices are on the same router as you and you are also connected to them in the meantime.



No comments:

Post a Comment

Sharepoint sync and lock issues - solutions

 Sharepoint synced down to your PC by onedrive can have a ton of errors. It is caused by the simple dis-functionality of this badly thought ...