All technological notes.
net-tools (deprecated)net-toolssudo yum install net-tools
rpm -aq | grep net-tools
ifconfig Utilityifconfig
interface configuration)ip command from the iproute suite.Device
| CMD | DESC |
|---|---|
ifconfig |
Display includes active network interfaces. |
ifconfig -a |
Display only active interfaces. |
ifconfig devce_id |
Display a specific network interface. |
ifconfig devce_id up |
Activates a specific network interface. |
ifconfig devce_id down |
Deactivates a specific network interface. |
| CMD | DESC |
|---|---|
ifconfig eth0 192.168.1.100 netmask 255.255.255.0 |
Assigns an IP address for a specific interface. |
ifconfig eth0 broadcast 192.168.1.255 |
Assigns a broadcast address to an interface. |
ifconfig devce_id hw ether new_MAC_address |
Change a new MAC address to a network interface. |
ifconfig: Interface Infoifconfig
# ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
# inet 192.168.204.153 netmask 255.255.255.0 broadcast 192.168.204.255
# inet6 fe80::20c:29ff:fe5b:ce78 prefixlen 64 scopeid 0x20<link>
# ether 00:0c:29:5b:ce:78 txqueuelen 1000 (Ethernet)
# RX packets 166189 bytes 241795084 (230.5 MiB)
# RX errors 0 dropped 0 overruns 0 frame 0
# TX packets 13913 bytes 2465843 (2.3 MiB)
# TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
# lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
# inet 127.0.0.1 netmask 255.0.0.0
# inet6 ::1 prefixlen 128 scopeid 0x10<host>
# loop txqueuelen 1000 (Local Loopback)
# RX packets 0 bytes 0 (0.0 B)
# RX errors 0 dropped 0 overruns 0 frame 0
# TX packets 0 bytes 0 (0.0 B)
# TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
# virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
# inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
# ether 52:54:00:c5:c9:4d txqueuelen 1000 (Ethernet)
# RX packets 0 bytes 0 (0.0 B)
# RX errors 0 dropped 0 overruns 0 frame 0
# TX packets 0 bytes 0 (0.0 B)
# TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens160Flags: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>
MTU (Maximum Transmission Unit):
mtu 1500: the maximum size of packets (in bytes) that can be transmitted without fragmentation.inet: 192.168.204.153: the IPv4 address assigned to the interface.netmask: 255.255.255.0: the subnet mask.broadcast: 192.168.204.255: the broadcast address.inet6: fe80::20c:29ff:fe5b:ce78: the link-local IPv6 address.prefixlen 64: Specifies the subnet mask for IPv6.scopeid: Indicates the scope of the address (<link> means it’s local to the link).ether 00:0c:29:5b:ce:78: the Media Access Control (MAC) address of the interface.txqueuelen 1000 (Ethernet): 1000 packets can be queued in the kernel for transmission before they are sent to the network hardware.EthernetRX packets 166189: The number of packets received.RX bytes 241795084 (230.5 MiB): Total data received.RX errors, dropped, overruns, frame: All error counts for received packets are 0.TX packets 13913: The number of packets transmitted.TX bytes 2465843 (2.3 MiB): Total data transmitted.TX errors, dropped, overruns, carrier, collisions: All error counts for transmitted packets are 0.loFlags: flags=73<UP,LOOPBACK,RUNNING>
UP: The interface is enabled.LOOPBACK: Indicates it is a loopback interface.RUNNING: The interface is operational.MTU (Maximum Transmission Unit):
mtu 65536 allows larger packet sizes since it does not involve physical hardware.virbr0Flags: flags=4099<UP,BROADCAST,MULTICAST>
UP: The interface is enabled.BROADCAST: Supports broadcasting.MULTICAST: Supports multicast.MTU (Maximum Transmission Unit):
mtu 1500: specifies the maximum packet size.# List all interfaces
ifconfig
# Get interface info
ifconfig ens224
# ens224: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
# inet 192.168.204.170 netmask 255.255.255.0 broadcast 0.0.0.0
# inet6 fe80::70eb:5c8e:a06e:f8e2 prefixlen 64 scopeid 0x20<link>
# ether 00:0c:29:5b:ce:82 txqueuelen 1000 (Ethernet)
# RX packets 2829 bytes 316014 (308.6 KiB)
# RX errors 0 dropped 0 overruns 0 frame 0
# TX packets 521 bytes 71586 (69.9 KiB)
# TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
# Deactivate an interface
ifconfig ens224 down
# verify
ifconfig ens224
# ens224: flags=4098<BROADCAST,MULTICAST> mtu 1500
# ether 00:0c:29:5b:ce:82 txqueuelen 1000 (Ethernet)
# RX packets 2927 bytes 325316 (317.6 KiB)
# RX errors 0 dropped 0 overruns 0 frame 0
# TX packets 544 bytes 74548 (72.8 KiB)
# TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
# Activate an interface
ifconfig ens224 up
# verify
ifconfig ens224
# ens224: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
# inet 192.168.204.171 netmask 255.255.255.0 broadcast 192.168.204.255
# inet6 fe80::70eb:5c8e:a06e:f8e2 prefixlen 64 scopeid 0x20<link>
# ether 00:0c:29:5b:ce:82 txqueuelen 1000 (Ethernet)
# RX packets 0 bytes 0 (0.0 B)
# RX errors 0 dropped 0 overruns 0 frame 0
# TX packets 10 bytes 1454 (1.4 KiB)
# TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
# rename an inerface
ifconfig ens224 | grep "inet "
# inet 192.168.204.171 netmask 255.255.255.0 broadcast 192.168.204.255
# shutdown an interface device
ifconfig ens224 down
# assign a static IP
ifconfig ens224 192.168.204.100
ifconfig ens224 netmask 255.255.255.0
# Activate the interface device
ifconfig ens224 up
# verify
ifconfig ens224 | grep "inet "
# inet 192.168.204.100 netmask 255.255.255.0 broadcast 192.168.204.255
systemctl reboot
ifconfig ens224 | grep "inet "
# inet 192.168.204.171 netmask 255.255.255.0 broadcast 192.168.204.255
route Utilityroute command
ip route commandRoute Table
| CMD | DESC |
|---|---|
route |
Display IP routing table |
route -n |
Display numerical addresses |
route add default gw 192.168.0.1 |
Add a Default Route |
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.0.1 |
Add a static route to a specific network |
route change -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.0.2 |
Change a Route |
route del -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.0.1 |
Delete a Route |
route -n
# Kernel IP routing table
# Destination Gateway Genmask Flags Metric Ref Use Iface
# 0.0.0.0 192.168.204.2 0.0.0.0 UG 100 0 0 ens160
# 0.0.0.0 192.168.204.2 0.0.0.0 UG 101 0 0 ens224
# 192.168.204.0 0.0.0.0 255.255.255.0 U 100 0 0 ens160
# 192.168.204.0 0.0.0.0 255.255.255.0 U 101 0 0 ens224
Destination:
0.0.0.0:
192.168.204.0: The
Gateway:
192.168.204.2: Indicates that traffic destined for the listed Destination will be sent via this gateway.0.0.0.0: Indicates that the destination is directly reachable (no gateway is required).Genmask:
0.0.0.0: Applies to all IP addresses (used for the default route).255.255.255.0: Applies to the subnet range 192.168.204.1–192.168.204.254.Flags:
U: The route is up (usable).G: The route uses a gateway.Metric:
100 and 101 are metrics for the respective routes.Ref:
Use:
Iface:
ens160 and ens224 are the interfaces for these routes.netstat Utilitynetstat command
largely replaced by the ss command in newer Linux distributions
| CMD | DESC |
|---|---|
netstat |
Display Active Network Connections |
netstat -t |
Display TCP Connections |
netstat -u |
Display UDP Connections |
netstat -l |
Display Listening Ports |
netstat -p |
Display Connections with Process Information |
netstat -tunlp |
Display Listening and Established Connections |
netstat -i |
Display Network Statistics |
netstat -r |
Display Routing Table |
netstat -rnv |
Display IP routing table |
netstat -rnv
# Kernel IP routing table
# Destination Gateway Genmask Flags MSS Window irtt Iface
# 0.0.0.0 192.168.204.2 0.0.0.0 UG 0 0 0 ens160
# 0.0.0.0 192.168.204.2 0.0.0.0 UG 0 0 0 ens224
# 192.168.204.0 0.0.0.0 255.255.255.0 U 0 0 0 ens160
# 192.168.204.0 0.0.0.0 255.255.255.0 U 0 0 0 ens224
Kernel IP Routing Table
Columns:
Destination:
Gateway:
0.0.0.0:
Genmask:
Flags:
U: The route is up (usable).G: The route uses a gateway.MSS:
Maximum Segment Size for TCP connections over this route (0 means default).Window:
irtt:
Initial round-trip time (unused here, often 0).Iface:
Default Route:
Destination:
0.0.0.0Gateway:
192.168.204.2Genmask:
0.0.0.0Flags: UG
Iface:
ens160 and ens224Local Subnet:
Destination:
192.168.204.0Gateway:
0.0.0.0Genmask:
255.255.255.0Flags: U
Iface:
ens160 and ens224