DEV Community

Mahbub Ferdous Bijoy
Mahbub Ferdous Bijoy

Posted on

Day-6: Network Troubleshooting, Network config, Dns

copy and rsync command:

  1. To copy a file over from local host to a remote host:
$ $ scp myfile.txt username@remotehost.com:/remote/directory

Enter fullscreen mode Exit fullscreen mode
  1. To copy a file from a remote host to your local host:
$ scp username@remotehost.com:/remote/directory/myfile.txt /local/directory

Enter fullscreen mode Exit fullscreen mode
  1. To copy over a directory from your local host to a remote host:
$ scp -r mydir username@remotehost.com:/remote/directory

Enter fullscreen mode Exit fullscreen mode
  1. rsync files on the same host:
$ rsync -zvr /my/local/directory/one /my/local/directory/two

Enter fullscreen mode Exit fullscreen mode
  1. rsync files to local host from a remote host:
$ rsync /local/directory username@remotehost.com:/remote/directory

Enter fullscreen mode Exit fullscreen mode
  1. rsync files to a remote host from a local host:
$ rsync username@remotehost.com:/remote/directory /local/directory

Enter fullscreen mode Exit fullscreen mode

simple server command :

  1. run simple python server command :
$ python -m SimpleHTTPServer

Enter fullscreen mode Exit fullscreen mode

here is network routing comamnd:

  1. Look at your machine's routing table:
$ route -n

Enter fullscreen mode Exit fullscreen mode
Gateway

If we are sending a packet that is not on the same network, it will be sent to this Gateway address. Which is aptly named as being a Gateway to another network.

Genmask

This is the subnet mask, used to figure out what IP addresses match what destination.

Flags

UG - Network is Up and is a Gateway
U - Network is Up
Iface

This is the interface that our packet will be going out of, eth0 usually stands for the first Ethernet device on your system.

Enter fullscreen mode Exit fullscreen mode
  1. add a new route :
$ sudo route add -net ip_address/cidr gw ip_addresss
$ ip route add ip_address via ip_address

Enter fullscreen mode Exit fullscreen mode
  1. delete any route :
$ sudo route del -net 192.168.2.1/23 
$ ip route delete 192.168.2.1/23

Enter fullscreen mode Exit fullscreen mode

network config command:

  1. network config command :
$ ifconfig 
$ ipconfig
$ ifconfig -a              [to see more details] 

Enter fullscreen mode Exit fullscreen mode
  1. To create an interface and bring it up:
$ ifconfig eth0 192.168.2.1 netmask 255.255.255.0 up

Enter fullscreen mode Exit fullscreen mode
  1. To bring up or down an interface:
$ ifup eth0
$ ifdown eth0

Enter fullscreen mode Exit fullscreen mode
  1. To show interface information for all interfaces:
$ ip link show

Enter fullscreen mode Exit fullscreen mode
  1. To show the statistics of an interface:
$ ip -s link show eth0

Enter fullscreen mode Exit fullscreen mode
  1. To show ip addresses allocated to interfaces:
$ ip address show

Enter fullscreen mode Exit fullscreen mode
  1. To bring interfaces up and down:
$ ip link set eth0 up
$ ip link set eth0 down

Enter fullscreen mode Exit fullscreen mode
  1. To add an IP address to an interface:
$ ip address add 192.168.1.1/24 dev eth0

Enter fullscreen mode Exit fullscreen mode
  1. To obtain a fresh IP:
$ sudo dhclient

Enter fullscreen mode Exit fullscreen mode

network manager command :

  1. There are also command-line tools to interact with NetworkManager:
$ nm-tool

Enter fullscreen mode Exit fullscreen mode
  1. The nmcli command allows you to control and modify NetworkManage:
$ nmcli

Enter fullscreen mode Exit fullscreen mode
  1. we lookup a MAC address with ARP command:
$ arp

Enter fullscreen mode Exit fullscreen mode
  1. You can also view your arp cache via the ip command::
$ ip neighbour show

Enter fullscreen mode Exit fullscreen mode

network troubleshoting command :

  1. One of the most simplest networking tools is ping
$ ping hostName or ip_address
$ ping google.com
$ ping -c google.com

Enter fullscreen mode Exit fullscreen mode
  1. The traceroute command is used to see how packets are getting routed. It works by sending packets with increasing TTL values, starting with 1:
$ traceroute hostName or Ip_address or google.com

Enter fullscreen mode Exit fullscreen mode
  1. An extremely useful tool to get detailed information about your network is netstat. Netstat displays various network related information such network connections, routing tables, information about network interfaces and more:
$ netstat
$ netstat -at

Enter fullscreen mode Exit fullscreen mode
  1. utility to debug TCP/UDP sockets:
$ nc

Enter fullscreen mode Exit fullscreen mode
  1. we can be used to test remote connectivity on ports by using telnet command:
$ telnet

Enter fullscreen mode Exit fullscreen mode
  1. mtr is a mix of ping and traceroute. It also provides additional information like intermediate hosts and responsiveness:
$ mtr

Enter fullscreen mode Exit fullscreen mode

here all DNS related linux command:

  1. The /etc/hosts file contains mappings of some hostnames to IP addresses:
$ cat /etc/hosts

Enter fullscreen mode Exit fullscreen mode
  1. The "name server lookup" tool is used to query name servers to find information about resource records:
$ nslookup DNSname or ip_address

Enter fullscreen mode Exit fullscreen mode
  1. Dig (domain information groper) is a powerful tool for getting information about DNS name servers:
$ dig DNSname or ip_address

Enter fullscreen mode Exit fullscreen mode

Top comments (0)