Note_Tech

All technological notes.


Project maintained by simonangel-fong Hosted on GitHub Pages — Theme by mattgraham

Linux - Networking: Package net-tools (deprecated)

Back


Package net-tools

sudo yum install net-tools
rpm -aq | grep net-tools

ifconfig Utility

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 Info

ifconfig
# 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




Lab: Activate/Deactivate an Interface

# 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

Lab: Assign a Static Runtime IP

# 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 Utility

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

Lab: Displays IP Routing Table

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

netstat Utility


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

Lab: Displays 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



TOP