Showing posts with label networking. Show all posts
Showing posts with label networking. Show all posts

Sunday, April 12, 2020

10 commands that you should know in Linux networking

networking

1. ifconfig - configure a network interface


examples : -

- View network settings of an ethernet adapter:

ifconfig eth0



- Display details of all interfaces, including disabled interfaces:

ifconfig -a



- Disable eth0 interface:

ifconfig eth0 down



- Enable eth0 interface:

ifconfig eth0 up



- Assign IP address to eth0 interface:

ifconfig eth0 ip_address


2. traceroute - to trace route or path of the packets to the destination machine

examples :

- Traceroute to a host:

traceroute host

  

- Disable IP address and host name mapping:

traceroute -n host

  

- Specify wait time for response:

traceroute -w 0.5 host

  

- Specify number of queries per hop:

traceroute -q 5 host

  

- Specify size in bytes of probing packet:

traceroute host 42

  

3.telnet - The telnet command is used for interactive communication with another host using the TELNET protocol.


- Telnet to the default port of a host:

telnet host



- Telnet to a specific port of a host:

telnet ip_address port



- Exit a telnet session:

quit



- Emit the default escape character combination for terminating the session:

Ctrl + ]



- Start telnet with "x" as the session termination character:

telnet -e x ip_address port

4.nslookup - nslookup is a program to query Internet domain name servers.


- Query your system's default name server for an IP address (A record) of the domain:

nslookup example.com



- Query a given name server for a NS record of the domain:

nslookup -type=NS example.com 8.8.8.8



- Query for a reverse lookup (PTR record) of an IP address:

nslookup -type=PTR 54.240.162.118



- Query for ANY available records using TCP protocol:

nslookup -vc -type=ANY example.com



- Query a given name server for the whole zone file (zone transfer) of the domain using TCP protocol:

nslookup -vc -type=AXFR example.com name_server



- Query for a mail server (MX record) of the domain, showing details of the transaction:

nslookup -type=MX -debug example.com



- Query a given name server on a specific port number for a TXT record of the domain:

nslookup -port=port_number -type=TXT example.com name_server

5. netstat - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.


- List all ports:

netstat -a



- List all listening ports:

netstat -l



- List listening TCP ports:

netstat -t



- Display PID and program names:

netstat -p



- List information continuously:

netstat -c



- List routes and do not resolve IP to hostname:

netstat -rn



- List listening TCP and UDP ports (+ user and process if you're root):

netstat -lepunt



- Print the routing table:

netstat -nr


6. ip - show / manipulate routing, devices, policy routing and tunnels


- List interfaces with detailed info:

ip a



- Display the routing table:

ip r



- Show neighbors (ARP table):

ip n



- Make an interface up/down:

ip link set interface up/down



- Add/Delete an ip address to an interface:

ip addr add/del ip/mask dev interface



- Add a default route:

ip route add default via ip dev interface


7. nmap - Network exploration tool and security / port scanner

- Try to determine whether the specified hosts are up and what are their names:

nmap -sn ip_or_hostname optional_another_address

  

- Like above, but also run a default 1000-port TCP scan if host seems up:

nmap ip_or_hostname optional_another_address

  

- Also enable scripts, service detection, OS fingerprinting and traceroute:

nmap -A address_or_addresses

  

- Assume good network connection and speed up execution:

nmap -T4 address_or_addresses

  

- Scan a specific list of ports (use -p- for all ports 1-65535):

nmap -p port1,port2,…,portN address_or_addresses

  

- Perform TCP and UDP scanning (use -sU for UDP only, -sZ for SCTP, -sO for IP):

nmap -sSU address_or_addresses

  

- Perform TLS cipher scan against a host to determine supported ciphers and SSL/TLS protocols:

nmap --script ssl-enum-ciphers address_or_addresses -p 443

  

8.ping - send ICMP ECHO_REQUEST to network hosts

- Ping host:

ping host

  

- Ping a host only a specific number of times:

ping -c count host

  

- Ping host, specifying the interval in seconds between requests (default is 1 second):

ping -i seconds host

  

- Ping host without trying to lookup symbolic names for addresses:

ping -n host

  

- Ping host and ring the bell when a packet is received (if your terminal supports it):

ping -a host

  

- Also display a message if no response was received:

ping -O host

9.ip link - network device configuration


ip link add [ link DEVICE ] [ name ] NAME



ip link set { DEVICE | group GROUP } { up | down | arp { on | off } } etc...



10. docker network command - Manage networks. You can use subcommands to create, inspect, list, remove, prune, connect, and disconnect networks.




docker network connect  Connect a container to a network

docker network create  Create a network

docker network disconnect  Disconnect a container from a network

docker network inspect  Display detailed information on one or more networks

docker network ls  List networks

docker network prune  Remove all unused networks

docker network rm  Remove one or more networks

Tuesday, February 28, 2017

why Python programming ...

Python is very effective when I want to learn a new thing like image processing, Machine learning , Networking...

You can directly jump into the functionality or subject area, I mean that your core subject area that you want to hack... there are lot libraries that support these  subject areas.

Last week I was reading a book 'Learn Python Network Programming' by Dr. M.O Faruque Sarker.

It is interesting that Python simplifies the subject 'Networking Protocols and Programming ' which i just byhearted in BTECH.

I experienced the same thing when I tried to learn about ML with Python.

Sunday, May 29, 2016

LXR Cross Referencer to read linux kernel source code

LXR Cross Referencer

This is the best place to refer one who like to know about linux kernel. http://lxr.free-electrons.com/ LXR Cross Referencer, usually known as LXR, is a general-purpose source code indexer and cross-referencer that provides web-based browsing of source code, with links to the definition and usage of any identifier.

I also found the following site is very helpful to start with linux kernels http://kernelnewbies.org/FirstKernelPatch

Saturday, May 28, 2016

Installed wireshark for Networking package analysis

WIRESHARK

Wireshark is a network protocol analyzer. This is actually nice tool which gives opportunity to analyze  and understand different network layers. Each packet  traffic is diplayed when we start browsing a website.Its very easy to install in Ubuntu using 'Ubuntu Software center'. After installing I used the command and changed to root. I am not sure any alternative way for getting my 'wlan0' wifi internet without changing to root.

sudo dpkg-reconfigure wireshark-common

started wireshark with 'sudo wireshark'



Saturday, October 3, 2015

Ubuntu internet wifi speed increase tip

Probably you can try the below steps in the Ubuntu machine to see whether your Internet speed is increasing or not

Step1:Put the below code in the bottom of the file using the bellow command



sudo vi /etc/sysctl.conf

net.core.rmem_default = 524288
net.core.rmem_max = 524288
net.core.wmem_default = 524288
net.core.wmem_max = 524288
net.ipv4.tcp_wmem = 4096 87380 524288
net.ipv4.tcp_rmem = 4096 87380 524288
net.ipv4.tcp_mem = 524288 524288 524288
net.ipv4.tcp_rfc1337 = 1
net.ipv4.ip_no_pmtu_disc = 0
net.ipv4.tcp_sack = 1
net.ipv4.tcp_fack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_ecn = 0
net.ipv4.route.flush = 1

Step2: run the below command
sudo sysctl -p

You can also disable your IPv6

Step1: go Wifi symbol and click it , you will get a edit connection option

Step2: select the wifi you are using and edit the configuration , in IPv6 configuration , select method as 'ingnore'