Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Managing network configurations is a crucial task for any systems engineer working with Linux environments. Linux offers a variety of tools and commands to efficiently handle network settings, monitor traffic, and troubleshoot issues. This article will guide you through the basics of network management in Linux, providing practical examples and commands to help you get started.
Examples:
Viewing Network Interfaces:
To list all network interfaces available on your Linux system, you can use the ip
command:
ip addr show
This command will display all network interfaces along with their IP addresses and other relevant information.
Configuring a Static IP Address:
To set a static IP address on a network interface, you can use the ip
command. For example, to set the IP address 192.168.1.100
on the interface eth0
, use:
sudo ip addr add 192.168.1.100/24 dev eth0
To make this change permanent, you need to edit the network configuration file, usually found in /etc/network/interfaces
or /etc/netplan/
depending on your Linux distribution.
Checking Network Connectivity:
To check connectivity to another host, the ping
command is commonly used:
ping -c 4 google.com
This command sends 4 ICMP echo requests to google.com
and displays the results.
Using netstat
for Network Statistics:
The netstat
command provides detailed network statistics. For example, to list all active connections and listening ports, use:
netstat -tuln
This command shows TCP/UDP connections and their listening ports.
Monitoring Network Traffic with iftop
:
iftop
is a real-time network bandwidth monitoring tool. To install and run iftop
, use:
sudo apt-get install iftop
sudo iftop -i eth0
Replace eth0
with your network interface name to monitor its traffic.
Managing Firewall with iptables
:
To allow incoming traffic on port 80 (HTTP), use the following iptables
command:
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
To save the changes, you might need to use a command specific to your distribution, such as sudo netfilter-persistent save
on Debian-based systems.