Skip to content

Tips for working with networks

Change system hostname

No system reboot is required

shell
hostnamectl set-hostname new-hostname

Addition: Hard reset for netip component network

shell
systemctl restart systemd-hostnamed && \
docker rm -f netip.network

and run reinstall components

Monitor network resource usage

For the interface eth0

shell
apt install tcptrack && \
tcptrack -i eth0

For port 443 only

shell
tcptrack -i eth0 port 443

Across all interfaces

shell
apt install nethogs && \
nethogs

Monitor UDP connections

shell
apt install conntrack -y && \
conntrack -L -p udp

Change DNS

Change DNS when using dhcpcd

shell
nano /etc/dhcpcd.conf
# add
interface ens160
static domain_name_servers=1.1.1.1 8.8.8.8
# or add for all interfaces
static domain_name_servers=1.1.1.1 8.8.8.8

# restart
systemctl restart networking.service

Change DNS when using dhclient

shell
nano /etc/dhcp/dhclient.conf
# add the following line
supersede domain-name-servers 1.1.1.1, 8.8.8.8;

# restart
systemctl restart networking.service

Hard Change DNS

If the above doesn't work, manually change it and lock the file

Change or Add nameserver to /etc/resolv.conf

To lock the file and restart

shell
chattr +i $(readlink -f /etc/resolv.conf) && \
systemctl restart networking.service

Rollback: To unlock the file

shell
chattr -i $(readlink -f /etc/resolv.conf) && \
systemctl restart networking.service && resolvconf -u

Working with UDP

Checking a port with nmap

If the port is closed, the state will be closed

shell
nmap -sU -p 53

Checking a port on the host

shell
ss -lunp | grep 53
# or
lsof -iUDP:53