network/

Change DNS nameservers using NetworkManager

sudo nmcli connection modify <connection name> ipv4.dns "1.1.1.1 8.8.8.8"

Apply changes:

sudo nmcli dev reapply <interface>
| 30 Dec 2021

How to reload the connection with NetworkManager

Reload interface configuration:

sudo nmcli connection reload

This command will ONLY make NetworkManager aware of new configuration changes. To apply the new changes, run the following command:

sudo nmcli dev reapply <interface>
| 30 Dec 2021

Connect dedicated servers with cloud servers in hetzner via vSwitch

Main article is provided by Hetzner team here. This article contains instructions for creating vlan interface in Centos 8 using nmcli.

Assumptions (same us in the main article + listed below):

  • VLAN ID is 4001
  • parent network interface is enp195s0

Steps:

  1. Create new connection:
nmcli connection add type vlan con-name vlan4001 ifname vlan4001 vlan.parent enp195s0 vlan.id 4001
  1. Configure the connection:
nmcli connection modify vlan4001 802-3-ethernet.mtu 1400
nmcli connection modify vlan4001 ipv4.addresses '10.0.1.2/24'
nmcli connection modify vlan4001 ipv4.gateway '10.0.1.1'
nmcli connection modify vlan4001 ipv4.dns '10.0.0.4'  # (optional)
nmcli connection modify vlan4001 ipv4.method manual
nmcli connection modify vlan4001 +ipv4.routes "10.0.0.0/16 10.0.1.1"
  1. Restart the connection
nmcli connection down vlan4001
nmcli connection up vlan4001
  1. Verify configuration
# Prints what gateway is used to reach the ip
ip route get 10.0.0.5

# Print all connection information
nmcli connection show vlan4001

# Print routing table
ip r

# Use tui interface for NetworkManager
dnf install NetworkManager-tui
nmtui

Restarting NetworkManager wasn’t enough to apply custom routes. Bring interface up and down

And the link to the great RedHat documentation

| 15 May 2021

netcat example

Listen on specified port:

nc -l -v -k 8888

Connect via netcat:

nc -v google.com 80
| 29 Mar 2021

Extract and count IP addresses from logs

journalctl -n 1000 | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | sort | uniq -c
| 29 Mar 2021

Debug route table

List all routes in system:

route -n

Get route for a specific IP:

ip route get 1.1.1.1
| 1 Jan 2020

Wait until able to connect

while ! nc -w5 -z 10.0.0.100 22; do echo "hello"; done
| 1 Jan 2020

Check and modify mtu of a connection

To check:

[root@lxd-node3 ~]# netstat -i
Kernel Interface table
Iface             MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
ens10            1450      455      0      0 0           671      0      0      0 BMRU
eth0             1500       28      0      0 0            32      0      0      0 BMRU
lo              65536        0      0      0 0             0      0      0      0 LRU

Modify temporarily:

ifconfig eth0 mtu 1450

Permanently: edit /etc/sysconfig/network-scripts/ifcfg-eth0 file and add:

MTU=1450

Might be the reason why the system can establish HTTP connection but HTTPS

| 1 Jan 2020

Useful wifi commands

List used wifi frequencies

sudo iwlist wlp1s0 scan | grep Frequency | sort | uniq -c | sort -n

List available channels

iwlist channel

List wifi networks

nmcli d wifi
| 1 Jan 2020

List all IP addresses in a network

To list ip addresses of all connected to the network devices, use this command:

nmap -sn 192.168.0.0/24
| 1 Mar 2018