Linux Network Administration with ping and ip Commands

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-network-administration-ping-ip-commands/
PINTEREST
PINTEREST
INSTAGRAM

Linux network stack is very powerful. Network stack provides a lot of functionalities where most of the enterprise network products can not offer. Here we will look basic and everyday network administration commands.

Check Network and Internet Connectivity

Network connectivity can be checked easily with ping and telnet tools. One method to check internet connectivity is ping to Google.

  • ping sends icmp packets
  • google.com is the destination of the icmp packets
  • line 3 and4 shows that google.com responds to our icmp packets
  • In line 2 216.58.212.46 is the ip address of the google.com and seeing this means our system can resolve domain names

Some  times ping can not be a feasible method to check internet connectivity. Because some network administrators disables icmp traffic in the network for security reasons. Here our alternative is telnet

  • telnet is the tool to make tcp connection
  • google.com is the destination system
  • 80 is port number of the system
  • Line 3 means there is no problem to make tcp connection to the google.com

If we see other than Line 3 it means there is a problem.

List Network Interfaces

Linux system can have multiple interfaces. Listing them can be done different ways but most used and modern way is using ip commands.

We issue ip link command and get all interfaces. Interfaces are numbered to be easily indentified.

LEARN MORE  Linux Avahi Daemon Tutorial With Examples

After the interface name came like ens .

After interface name the status of the interface cames. There are different options but most important is UP and DOWN option. If there is DOWN status it shows there is a problem or the interface is not set UP .

And there is MAC address like 52:54:00:ea:3f:9c .

Setting Interface UP/DOWN

We can set an interface with ip link command by using set .

We have set down the interface and than list the status of the interface. Now we can set up the interface again. Keep in mind if an interface is set down the network communication about the interface will be down.

Good, everything works as what is expected. We simple used up argument instead of down . If there is an dhcp server in the interface network it will get an ip address as soon as possible.

List IP Adress

Listing ip address is easy. All interfaces ip addresses will be listed.

We may want to list specific ip address. Because in enterprise systems there will be a lot of interface and ip addreses.

LEARN MORE  Python Script Change Mac Address Periodically

Setting IP Address

We want to set ip address statically. If dhcp is enable in the interface network it will get automatically an ip address.

Our interface has all ready an ip address.

  • add specifies that we want to add an ip address
  • 192.168.122.107/24 is ip address and netmask
  • dev ens3 is the interface we want to set ip address
LEARN MORE  How To Start, Stop, Restart Networking On Linux?

Remove IP Address

Removing ip address is similar to adding just add command is substituted with del command.

As we see previously added ip address is removed.

List Routing Table

Routing table is a crucial part of the networking because the network packets are sent to the destination according to routing table. We can check routing table like below

  • route means we will use routing submodule
  • show lists the routing table content

Add Static Routing

Static route is a new route that is inserted by system administrator. Normally routing entries are inserted by system itself.

  • add used to add new route entry
  • 10.0.0.0/24 specifies destination network
  • via 192.168.122.1 sets next hoop to destination network
  • dev ens3 is the network interface where packet go out for the destination network

Remove Static Route

Removing static route is easier than adding it.

  • del issued for removel
  • 10.0.0.0/24 specifies the destination network which route will be removed

Adding Default Gateway

Default gateway is a route too. But default gateway is special because if there is no entry on the route table about destination network, packets are forwarded through default gateway.

  • default means the destination is all networks
  • via 192.168.122.1 specifies default gateway ip address

Removing Default Gateway

Default gateway can be removed easyli just changing add in the adding command to del like below

  • del delete this route
  • default route is default gateway
  • via 192.168.122.1 the ip address of default gateway
RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-network-administration-ping-ip-commands/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)