0% found this document useful (0 votes)
5 views

Linux Network Commands

Uploaded by

zakiya hassan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Linux Network Commands

Uploaded by

zakiya hassan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

# Network Service Commands in Linux

## 1. Checking Network Interfaces


- ifconfig: Displays network interfaces and their configurations.
Example: ifconfig
- ip addr: Displays the IP addresses assigned to all interfaces.
Example: ip addr
- ip link: Displays and controls network interfaces.
Example: ip link

## 2. Configuring Network Interfaces


- ip link set <interface> up: Activates a network interface.
Example: ip link set eth0 up
- ip link set <interface> down: Deactivates a network interface.
Example: ip link set eth0 down
- ifconfig <interface> up: Activates a network interface (older command).
Example: ifconfig eth0 up
- ifconfig <interface> down: Deactivates a network interface (older command).
Example: ifconfig eth0 down

## 3. Viewing Routing Table


- netstat -r: Displays the routing table.
Example: netstat -r
- ip route: Displays the routing table in a more detailed format.
Example: ip route

## 4. Managing Network Connections


- ping <hostname or IP>: Checks the connectivity to a host.
Example: ping 192.168.1.1
- traceroute <hostname or IP>: Traces the route packets take to reach the
destination.
Example: traceroute google.com
- dig <hostname>: Queries DNS to resolve a hostname.
Example: dig google.com
- nslookup <hostname>: Another DNS lookup tool.
Example: nslookup google.com

## 5. Configuring DNS
- cat /etc/resolv.conf: Displays DNS configuration.
Example: cat /etc/resolv.conf
- systemctl restart network: Restart the network service (for CentOS, RHEL).
Example: systemctl restart network
- systemctl restart networking: Restart the network service (for Ubuntu/Debian).
Example: systemctl restart networking

## 6. Viewing Active Connections


- netstat -tuln: Displays all listening ports and active connections.
Example: netstat -tuln
- ss -tuln: More modern tool to display active sockets and connections.
Example: ss -tuln
- lsof -i: Shows which processes are using network connections.
Example: lsof -i

## 7. Managing Network Services


- systemctl status <service>: Displays the status of a network service (e.g., sshd,
apache2).
Example: systemctl status sshd
- systemctl start <service>: Starts a network service.
Example: systemctl start sshd
- systemctl stop <service>: Stops a network service.
Example: systemctl stop sshd
- systemctl restart <service>: Restarts a network service.
Example: systemctl restart sshd

## 8. Firewall Configuration (Using UFW or firewalld)


- ufw status: Displays the current status of the UFW firewall.
Example: ufw status
- ufw allow <port>: Allows traffic on a specific port.
Example: ufw allow 80/tcp
- ufw deny <port>: Denies traffic on a specific port.
Example: ufw deny 80/tcp
- firewall-cmd --zone=public --add-port=80/tcp --permanent: Opens port 80 on
firewalld.
Example: firewall-cmd --zone=public --add-port=80/tcp --permanent
- firewall-cmd --reload: Reloads firewalld configuration after changes.
Example: firewall-cmd --reload

## 9. Network Services Status


- systemctl is-active <service>: Checks if a network service is active.
Example: systemctl is-active network-manager
- systemctl is-enabled <service>: Checks if a service is enabled to start at boot.
Example: systemctl is-enabled network-manager

## 10. Displaying Network Interfaces (More Detailed)


- ip -s link: Displays detailed statistics about each network interface.
Example: ip -s link

You might also like