Basic Linux Network commands, you deserve

Source: Internet
Author: User
Tags echo message nslookup

Basic Linux Network commands, you deserve
GuideAmbitious Linux system administrators and Linux enthusiasts must know the most important and basic collection of Linux Network commands. In It's FOSS, we don't talk about Linux's "command line" every day ". Basically, I focus more on Linux desktops. However, some of your readers pointed out in an internal survey (only for It's FOSS newsletter subscribers) that you also want to learn command line skills. Quick query tables are also favored and supported by most readers.

To this end, I edited a list of basic network commands in Linux. It is not a tutorial that teaches you how to use these commands, but a collection of commands and their brief explanations. Therefore, if you have used these commands, you can use them to quickly remember the commands.

You can add this webpage as a bookmarks for quick reference, or output a PDF version for offline use.

When I was a communication system engineering student, I had a list of Linux Network commands. It helped me get a high score in my computer network course. I hope it will help you in the same way.

Linux basic network command list

I use FreeBSD on a computer network course, but these UNIX commands should also work on Linux.

Connectivity
  • Ping
  • Telnet
  • 7 -- echo port
  • 25 -- SMTP, used to send emails
  • 79 -- Finger ?), Provides information about other users in the network.
ARP

ARP is used to convert an IP address to an ethernet address. Root users can add and delete ARP records. Deleting ARP records is useful when they are contaminated or incorrect. The ARP record explicitly added by root is permanent-so is the proxy settings. ARP tables are stored in the kernel and are dynamically operated. ARP records will be cached, usually expire and deleted in 20 minutes.

  • • Arp-a: print the ARP table.
  • • Arp-s <ip_address> <mac_address> [pub]: Add a record to the table.
  • • Arp-a-d: delete all records in the ARP table.
Routing
  • • Netstat-r: print the route table. The route table is saved in the kernel and used to Route packets to a non-local network at the IP layer.
  • • Route add: route: Used to add static (manually specified rather than dynamic) routing paths to the route table. All traffic from the PC to that IP address/subnet will go through the specified gateway IP address. It can also be used to set a default route.
    For example, if 0.0.0.0 is used in an IP address/subnet, all packets can be sent to a specific gateway.
  • • Routed: the BSD daemon that controls dynamic routing. Start at startup. It runs the RIP routing protocol. Only root users are available. You cannot run it without the root permission.
  • • Gated: gated is another routing daemon that uses the RIP Protocol. It supports both OSPF, EGP, and RIP protocols. Only root users are available.
  • • Traceroute: used to track routes of IP packets. Each time a packet is sent, it adds the number of hops to 1, so that all gateways from the source address to the destination will return messages.
  • • Netstat-rnf inet: displays the IPv4 route table.
  • • Sysctl net. inet. ip. forwarding = 1: enable packet forwarding (turning the host into a router ).
  • • Route add | delete [-net |-host] <destination> <gateway> :( for example, route add 192.168.20.0/24 192.168.30.4) add a route.
  • • Route flush: delete all routes.
  • • Route add-net 0.0.0.0 192.168.10.2: add a default route.
  • • Routed-Pripv2-Pno_rdisc-d [-s |-q]: runs the routed daemon, uses the RIPv2 Protocol, does not enable ICMP automatic discovery, and runs on the foreground, supply Mode or quiet mode.
  • • Route add 224.0.0.0/4 127.0.0.1: defines multicast routes for local addresses. (LCTT comments: the original article has doubts)
  • • Rtquery-n
Others
  • • Nslookup: to query the DNS server, convert the IP address to a name, or vice versa. For example, nslookup facebook.com will give the IP address of facebook.com.
  • • Ftp
  • • Rlogin-l
Important files
  • •/Etc/hosts: ing of domain names to IP addresses.
  • •/Etc/networks: ing Network names to IP addresses.
  • •/Etc/protocols: ing protocol names to protocol numbers.
  • •/Etc/services: ing of TCP/UDP Service names to port numbers.
Tool and Network Performance Analysis
  • • Ifconfig <interface> <address> [up]: the startup interface.
  • • Ifconfig <interface> [down | delete]: Stop interface.
  • • Ethereal & amp;: Enable ethereal in the background instead of the foreground.
  • • Tcpdump-I-vvv: A Tool for capturing and analyzing packages.
  • • Netstat-w [seconds]-I [interface]: displays network settings and statistics.
  • • Udpmt-p [port]-s [bytes] target_host: Send UDP traffic.
  • • Udptarget-p [port]: receives UDP traffic.
  • • Tcpmt-p [port]-s [bytes] target_host: Send TCP traffic.
  • • Tcptarget-p [port]: receives TCP traffic.
Vswitch
  • • Ifconfig sl0 srcIP dstIP ifconfig sl0 srcIP dstIP: configure a serial interface (first run slattach-l/dev/ttyd0, then run sysctl net. inet. ip. forwarding = 1)
  • • Telnet 192.168.0.254: access the switch from a host in the subnet.
  • • Sh ru or show running-configuration: view the current configuration.
  • • Configure terminal: Enter the configuration mode.
  • • Exit: exit the current mode. (LCTT comments: the original article has doubts)
VLAN
  • • Vlan n: Create a VLAN with ID n.
  • • No vlan N: delete VLAN with ID n.
  • • Untagged Y: add Port Y to VLAN n.
  • • Ifconfig vlan0 create: create vlan0 interface.
  • • Ifconfig vlan0 vlan_ID vlandev em0: Add em0 to the vlan0 interface (LCTT Note: original text is suspect) and set it to ID.
  • • Ifconfig vlan0 [up]: enables virtual interfaces.
  • • Tagged Y: adds frame marking Support for port Y of the current VLAN.
UDP/TCP
  • • A socklab udp: Run socklab using UDP protocol.
  • • Sock: Creates a UDP socket, which is equivalent to inputting sock udp and bind.
  • • Sendto <Socket ID>
  • • Recvfrom <Socket ID> <byte #>: receives data from the Socket.
  • • Socklab tcp: Use the TCP protocol to run socklab.
  • • Passive: Creates a passive socket, which is equivalent to socklab, sock tcp, bind, and listen.
  • • Accept: The accepted connection (which can be executed before or after the initiated connection ).
  • • Connect
  • • Close: close the connection.
  • • Read <byte #>: reads n Bytes from the socket.
  • • Write: (for example, write ciao, write #10) write "ciao" or 10 bytes to the socket.
NAT/Firewall
  • • Rm/etc/resolv. conf: disables address resolution to ensure that your filtering and firewall rules work correctly.
  • • Ipnat-f file_name: Write filtering rules to files.
  • • Ipnat-l: displays the list of active rules.
  • • Ipnat-C-F: reinitialize the rule table.
  • • Map em0 192.168.1.0/24-> 195.221.227.57/32 em0: map IP addresses to interfaces.
  • • Map em0 192.168.1.0/24-> 195.221.227.57/32 portmap tcp/udp 20000: 50000: ing with port number.
  • • Ipf-f file_name: Write filtering rules to files.
  • • Ipf-F-a: resets the rule table.
  • • Ipfstat-I: when used together with the-s option, it lists the status entries of the activity ).

I hope this basic Linux network command collection will be useful. You are welcome to all kinds of questions and suggestions.

From: https://linux.cn: 443/article-7801-1.html

Address: http://www.linuxprobe.com/linux-network-command.html


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.