Common commands:
ip |
Command to show and manipulate network devices and routing |
ifconfig |
Deprecated command for configuring network devices |
route |
Deprecated command for managing network routes |
ifup/down |
Bring a network interface up or down |
ss |
Show socket connections |
netstat |
Deprecated command for showing network connection |
arp |
Deprecated command for showing ARP information |
ip
Global command to manage networking
Common sub-commands:
address
protocol (IP or IPv6) address on a device
link
network device
route
routing table entry
Common Actions: add
, delete
, show
(or list
)
Can use short cuts for sub-commands
# Assign an IP address to a specific interface
ip addr add 192.168.50.5 dev eth1
# Set an IP with a specific netmask
ip addr add 192.168.50.5/23 dev eth1
# Remove an IP address (best to use full CIDR)
ip addr del 192.168.50.5/23 dev eth1
# Show all interfaces
ip addr show
# Show a specific interface
ip addr show dev eth1
This replaces ifconfig
.
# Bring an interface up
ip link set eth1 up
# Bring an interface down
ip link set eth1 down
# Set the MTU
ip link set eth1 mtu 9000
This replaces ifconfig
.
# Adding the default gateway
ip route add default via 192.168.50.1
# Add a static route
ip route add 10.20.10.0/24 via 192.168.50.1
# Remove a static route
ip route del 10.20.10.0/24
# Show route table
ip route show
This replaces route
.
# Show ARP table
ip neigh
# Show verbose ARP table
ip -s neigh
# Add new ARP table entry
ip neigh add 192.168.50.20 lladdr 1:2:3:4:5:6 dev eth1
# Remove ARP table entry
ip neigh del 192.168.50.20 dev eth1
This replaces arp
.
# Show all network stats
ss
# Show all TCP network stats without DNS lookups
ss -nt
# Show multicast addresses
ip maddr
This replaces netstat
.
NetworkManager
nmtui
NetworkManager
nmcli
NetworkManager
/etc/sysconfig/network-scripts
ifcfg
files in this directory/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
# Static
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
PREFIX=24
IPADDR=10.0.1.27
# DHCP
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
NetworkManager needs to be made aware of the change by running:
nmcli connection reload
Or if you only want it to change the file you changed:
nmcli con load /etc/sysconfig/network-scripts/ifcfg-eth0
Bringing the interface up:
ifup eth0
# OR
nmcli con up eth0
eth0
, eth1
, etceth0
vs. enp5s0
)By default, systemd
uses the following policies for naming:
eno1
)ens1
)enp2s0
)enx78e7d1ea46da
)eth0
)Can be disabled with net.ifnames=0 biosdevname=0
set at boot
Two character prefixes:
en |
Ethernet |
wl |
Wireless (WLAN) |
ww |
Wireless wide network (WWAN) |
Device Name Types:
o<index>
s<slot>[f<function>][d<dev_id>]
x<MAC>
p<bus>s<slot>[f<function>][d<dev_id>]
Example:: enP2p1s0f4