
Linux Command Line
The ‘ip’ command on Linux is a powerful tool for managing and configuring network interfaces. It can be used to display and modify the configuration of network interfaces, routes, and firewall rules.
When to use the ‘ip’ command:
- To view the current status and configuration of network interfaces
- To add or remove network interfaces
- To configure IP addresses and routes
- To manage firewall rules
- To troubleshoot network issues
Examples of common ‘ip’ command usage:
- Display information about all network interfaces:
ip addr show
- Assign a static IP address to a network interface:
ip addr add 192.168.1.100/24 dev eth0
- Delete an IP address from a network interface:
ip addr del 192.168.1.100/24 dev eth0
- Display firewall rules:
ip firewall show
- Add a firewall rule to accept incoming SSH connections:
ip firewall add accept ssh
- Delete a firewall rule:
ip firewall del accept ssh
More in ‘ip route’
The ip route
command is used to manage the routing table on a Linux system. The routing table is used to determine the path that network packets should take to reach their destination.
Examples of common ip route
usage:
- Display the current routing table:
ip route show
- Add a route for a specific network:
ip route add 192.168.1.0/24 via 192.168.1.1
- Delete a route:
ip route del 192.168.1.0/24
- Add a default route to a gateway:
ip route add default via 192.168.1.1
- Add a route for a specific host:
ip route add 192.168.1.100 via 192.168.1.1
- Add a route with a specific metric:
ip route add 192.168.1.0/24 via 192.168.1.1 metric 3
The ip route
command allows you to manipulate the routing table on your Linux system. You can add, delete and display routes with different options and parameters. This command is useful when you need to configure static routes, troubleshoot routing issues or manage multiple default gateways.
The ‘ip’ command is a versatile tool that can help you to manage and troubleshoot your Linux network. With the examples above you can start configuring your network interfaces, ip addresses, routes and firewall rules easily. Remember that you can use the man page of the command to see more options and information.