this repo has no description
Network Configuration by Distribution#
Viewing Current Configuration#
Show IP addresses:
ip a
# or
ip addr show
Show specific interface:
ip a show eth0
Kali/Debian - /etc/network/interfaces#
File: /etc/network/interfaces
Basic static configuration:
auto eth0
iface eth0 inet static
address 172.20.118.100
netmask 255.255.255.0
gateway 172.20.118.1
Key components:
auto eth0- Bring up interface automatically on bootiface eth0 inet static- Configure static IP (not DHCP)address- IP addressnetmask- Subnet maskgateway- Default gateway (router)
Restart networking:
sudo systemctl restart networking
# or
sudo ifdown eth0 && sudo ifup eth0
CentOS/RHEL - ifcfg Files#
Directory: /etc/sysconfig/network-scripts/
Files: One per interface (e.g., ifcfg-eth0, ifcfg-eth1)
Example ifcfg-eth0:
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=172.20.118.1
NETMASK=255.255.255.0
GATEWAY=172.20.118.254
Key settings:
DEVICE- Interface nameBOOTPROTO-staticordhcpONBOOT-yesto auto-start on bootIPADDR- IP addressNETMASK- Subnet maskGATEWAY- Default gateway
Restart networking:
sudo systemctl restart network
# or per-interface:
sudo ifdown eth0 && sudo ifup eth0
Ubuntu - Netplan (YAML)#
Directory: /etc/netplan/
File: Usually 01-network-manager-all.yaml (or similar .yaml file)
IMPORTANT: YAML is whitespace-sensitive. Use 2-space indentation consistently.
Example configuration:
network:
version: 2
renderer: NetworkManager
ethernets:
ens18:
addresses:
- 192.168.195.2/24
gateway4: 192.168.195.1
Key elements:
ethernets:- Section for ethernet interfacesens18:- Interface name (not eth0 on modern Ubuntu)addresses:- List of IPs (note the dash and/24CIDR notation)gateway4:- Default gateway for IPv4
Apply changes:
sudo netplan apply
Test configuration (doesn't persist):
sudo netplan try
CIDR notation: /24 equals 255.255.255.0
Temporary IP Configuration#
Set IP temporarily (lost on reboot):
sudo ip addr add 192.168.1.100/24 dev eth0
Flush (remove) all IPs from interface:
sudo ip addr flush dev eth0
Common Network Issues#
- Wrong interface name: Check with
ip afirst - Typo in config file: Double-check spelling and syntax
- Forgotten gateway: Can't reach beyond local network
- Netplan spacing: YAML requires exact indentation
- Wrong subnet: Devices must be on same subnet to communicate
Interface Naming#
- Old style:
eth0,eth1,lo(loopback) - New style:
ens18,enp0s3, etc. (Ubuntu/modern systems) - Always check actual names with
ip abefore configuring