Network
Configuring Network using Netplan
Edit /etc/netplan/*
Apply config: sudo netplan apply
https://linuxconfig.org/ubuntu-22-04-network-configuration
Enable Wake On LAN in Linux
Enable Wake On LAN in BIOS
Get current config: nmcli connection show "Wired connection 1" | grep 80
search for: 802-3-ethernet.wake-on-lan: default
Set default setting to magic to enable wake on lan: sudo nmcli connection modify "Wired connection 1" 802-3-ethernet.wake-on-lan magic
Disable wake on lan: sudo nmcli connection modify "Wired connection 1" 802-3-ethernet.wake-on-lan disabled
Check if WOL magic packet is received: sudo nc -u -l -p 9
To send magic packet from a linux machine: use wakeonlan $macaddress or etherwake $macaddress
Configure Network
Check network interface
ip -4 -br a: View IPv4 address of all interfaces in brief format
conntrack -L: show connection tables
sipcalc 192.168.1.0/24: calculate ip addresses
Configure routing
Routing configuration file: /etc/iproutes/rt_tables
ip route add default via 192.168.1.1 table wan1: add default gateway for routing table wan1 (like vrf)
ip route add 1.1.1.1 via 192.168.1.1 metric 100
sysctl net.ipv4.fib_multipath_hash_policy: get multipath settings
sysctl -w net.ipv4.fib_multipath_hash_policy=1: enable multipath
ip route add 1.1.1.1 nexthop via 192.168.1.1 nexthop via 192.168.2.1: set route for multipath
ip route add unreachable 2.2.2.2: set null0 route, source receives Host unreachable icmp
ip route add prohibit 3.3.3.3: set null0 route, source receives packet filtered icmp
ip route add blackhole: set null0 route, packet is silently dropped. This route is used in BGP to advertise route not in routing table
Policy-based routing
ip rule: check routing rule, lower rule is checked first
ip rule add from 10.0.0.0/24 table wan1
ip rule add from 20.0.0.0/24 table wan2
ip rule add fwmark 100 table wan1: route traffic based on firewall mark 100
ip rule add fwmark 200 table wan2: route traffic based on firewall mark 200
ip rule add lookup main suppress_prefixlength 0: lookup routing table main for all route except for route to /0 (default route)
Check Routing table
ip route get 8.8.8.8 [fibmatch]: get ip route to 8.8.8.8
ip route get 8.8.8.8 from 10.1.1.1 fibmatch: check policy-based routing
ip route show scope host table all
ip route show scope link table all
ip route show global
ip route show [table local | main]
Configuring Network using Network Manager
systemctl restart NetworkManager: restart Network Manager
Enable Vlan
sudo apt update
sudo apt install vlan: for Ubuntu/Debian
sudo yum install vconfig: for RHEL/CentOS
sudo modprobe 8021q: enable VLAN support in the kernel
echo "8021q" | sudo tee -a /etc/modules: make it persistent
Create VLAN configuration
Change Interface Address from dhcp to manual
Change Interface Address from manual to dhcp
Change interface name to eth0
Disable Ip Address on interface (no DHCP or manual address)
Verification
nmcli con show
ip addr show enp86s0.2
ip addr show enp86s0.4
check configuration files in /etc/NetworkManager/system-connections/
Configure Network using ip command
View ARP Table
arp -a
ip neigh show
ip -s neigh show: view with details
cat /proc/net/arp
Reference
Last updated