Category Archives: Network

I found two ways to configure the /etc/resolv.conf file to prevent it to be overridden by the system.

  1. Edit the base file under the resolv.conf.d file
sudo vim /etc/resolvconf/resolv.conf.d/base

and then add the nameservers to the file:

nameserver 8.8.8.8
nameserver 8.8.4.4

lastly, update resolvconf:

sudo resolvconf -u

2. Install dnsmasq and edit /etc/dnsmasq.conf to add the nameservers you want.

sudo apt install dnsmasq
and
vim /etc/dnsmasq.conf

Then restart the network services:

sudo service dnsmasq restart and
sudo service network-manager restart

You should be all set now.

References:
1. https://unix.stackexchange.com/questions/128220/how-do-i-set-my-dns-when-resolv-conf-is-being-overwritten

2. https://unix.stackexchange.com/questions/128220/how-do-i-set-my-dns-when-resolv-conf-is-being-overwritten/163506#163506

Cheers!

Advertisements

Static IP config with netplan (ubuntu)

If you use a modern Ubuntu distribution (the latest 18.04 LTS or 17.XX), you might have noticed that the package to configure the network changed.

Ubuntu changed to Netplan, that is more modern and relatively simpler to use. The file configuration for a static IP should be as follows.

# cat /etc/netplan/01-netcfg.yaml
network:
 version: 2
 renderer: networkd
 ethernets:
 eth0:
 dhcp4: no
 addresses: [YOUR.STATIC.IP.ADDRESS/24]
 gateway4: X.X.X.X
 nameservers:
 addresses: [YY.YY.YY.YY, 8.8.8.8]

Reference: I extracted the following information from  https://ppc64el.wordpress.com/2018/03/22/ubuntu-18-04-netplan/

Please visit the link above for more information (including the original /etc/network/interfaces format of the eth0 interface before the transition to netplan).

Cheers!

Find out your gateway IP address

There are two ways of collecting the IP address of your current Gateway:

  1. netstat -r
  2. route -n

The output of both commands are the almost the same:

12:29:25 ✔ dbkreling:~$ sudo netstat -r
[sudo] password for dbkreling:
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         192.168.0.1     0.0.0.0         UG        0 0          0 wlan0
172.17.0.0      *               255.255.0.0     U         0 0          0 docker0
192.168.0.0     *               255.255.255.0   U         0 0          0 wlan0

12:29:36 ✔ dbkreling:~$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 wlan0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.0.0     0.0.0.0         255.255.255.0   U     9      0        0 wlan0

In my case above IP 192.168.0.1 is the gateway for my connection. The flag U indicates that route is up and G indicates that it is gateway.

Cheers!