Guide |
The most important and basic Linux Network command collection that aspiring Linux system administrators and Linux enthusiasts must know. At It's FOSS we are not talking about the "command line aspect" of Linux every day. Basically, I'm more focused on the desktop side of Linux. But some of your readers in-house surveys (It's FOSS newsletter subscribers only) point out that you also want to learn some command-line tricks. The Quick check table is also popular with most readers. |
To do this, I edited a list of basic network commands in Linux. It's not a tutorial that teaches you how to use these commands, but rather a collection of commands and their short explanations. So, if you've already used these commands, you can use it to quickly remember commands.
You can add this page as a bookmark for quick reference, or output a PDF version for offline use.
I had this list of Linux network commands when I was a student of communication systems engineering. It helped me get a high score on the computer network course. Hopefully 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 of
- • Ping sends an ICMP echo message (a packet) to the host. This may continue to be sent until you press control-c,ping to mean that a packet is sent out via ICMP from your machine and echoed in the IP layer. Ping tells you if another host is running.
- • telnet communicates with the host on the specified port. The default Telnet port is 23. Press control-] to exit Telnet. Some of the other commonly used ports are:
- 7--echo Port
- 25--SMTP, for sending mail
- 79--finger (lctt: Wikipedia-Finger protocal, but for example Finger I'm afraid it's inappropriate, why not try 80? ) To provide information about other users under the network.
ARPARP is used to convert an IP address to an Ethernet address. The root user can add and remove ARP records. It can be useful to delete ARP records when they are contaminated or wrong. The ARP record that is explicitly added by root is permanent-the proxy setting is also. The ARP table is stored in the kernel and is dynamically manipulated. ARP records are cached and typically expire after 20 minutes and are deleted.
- arp-a: prints the ARP table.
- arp-s <ip_address> <mac_address> [pub]: add a record to the table.
- arp-a-D: deletes all records in the ARP table.
Routing
- netstat-r: Prints the routing table. The routing table is stored in the kernel and is used by the IP layer to route packets to non-local networks.
- Route Add:route: used to add static (manually specified rather than dynamic) routing paths to the routing table. All traffic from that PC to that ip/subnet goes through the specified gateway IP. It can also be used to set a default route.
For example, using 0.0.0.0 at the ip/subnet, you can send all packages to a specific gateway.
- routed: BSD daemon that controls dynamic routing. Start up at boot time. It runs the RIP routing protocol. Only the root user is available. You cannot run it without root privileges.
- gated:gated is another routing daemon that uses the RIP protocol. It supports both OSPF, EGP, and RIP protocols. Only the root user is available.
- traceroute: The route used to track IP packets. It adds 1 hops each time it sends a packet, allowing all gateways from the source address to the destination to return a message.
- netstat-rnf inet: Displays the route table for IPV4.
- sysctl net.inet.ip.forwarding=1: Enable packet forwarding (turn the host into a router).
- Route add|delete [-net|-host] <destination> <gateway>:(such as route add 192.168.20.0/24 192.168.30.4) add a route.
- Route flush: removes all routes.
- Route add-net 0.0.0.0 192.168.10.2: adds a default route.
- routed-pripv2-pno_rdisc-d [-s|-q]: runs the routed daemon, uses the RIPV2 protocol, does not enable ICMP Autodiscover, runs in the foreground, provisioning mode, or Quiet mode.
- route add 224.0.0.0/4 127.0.0.1: defines a multicast route for the local address. (LCTT: The original is doubtful)
- rtquery-n queries the RIP daemon on the specified host (manually updating the routing table).
other
- nslookup: query to DNS server, turn IP to name, or vice versa. For example, Nslookup facebook.com will give Facebook.com IP.
- • FTP transfer files to the specified host. You can usually log in using the login name "anonymous" and the password "guest".
- rlogin-l Log on to the host with a virtual terminal like Telnet.
Important Documents
- /etc/hosts: domain-to-IP-address mapping.
- /etc/networks: Network Name-to-IP address mapping.
- /etc/protocols: The mapping of the Protocol name to the protocol number.
- /etc/services: TCP/UDP the mapping of the service name to the port number.
Tools and network performance analysis
- ifconfig <interface> <address> [up]: start interface.
- ifconfig <interface> [down|delete]: stop interface.
- ethereal &: open ethereal in the background instead of the foreground.
- tcpdump-i-VVV: a tool for crawling 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]: receive UDP traffic.
- tcpmt-p [Port]-s [bytes] Target_host: sends TCP traffic.
- tcptarget-p [port]: receives TCP traffic.
Switch
- ifconfig sl0 srcip dstip ifconfig sl0 srcip dstip: Configure a serial interface (Slattach-l/dev/ttyd0 before performing sysctl net.inet.i after p.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 configuration mode.
- exit: exits the current mode. (LCTT: The original is doubtful)
VLAN
- VLAN N: creates a VLAN with an ID of N.
- • No VLAN N: deletes the VLAN with the ID N.
- untagged y: add port y to VLAN N.
- ifconfig vlan0 Create: creates the Vlan0 interface.
- ifconfig vlan0 vlan_id vlandev em0: add em0 to the Vlan0 interface (LCTT: The original is in doubt) and set the tag as ID.
- ifconfig vlan0 [up]: enables the virtual interface.
- Tagged y: adds tag frame support for Port y of the current VLAN.
udp/tcp
- • A socklab udp: runs Socklab using the UDP protocol.
- Sock: creates a UDP socket equivalent to input sock UDP and bind.
- sendto <socket id> send packet.
- recvfrom <socket id> <byte #>: receives data from the socket.
- Socklab tcp: runs Socklab using the TCP protocol.
- Passive Passive: creates a passive mode socket, equivalent to Socklab, sock TCP, bind, listen.
- Accept: accepts incoming connections (can be performed before or after initiating a connection).
- Connect equivalent to Socklab, sock TCP, bind, connect.
- Close: closes the connection.
- read <byte #>: reads n bytes from the socket.
- Write:(for example, write Ciao, write #10) writes a "ciao" or 10 bytes to the socket.
nat/Firewall
- rm/etc/resolv.conf: prohibit address resolution to ensure that your filtering and firewall rules work correctly.
- ipnat-f file_name: writes the filter rule to the file.
- ipnat-l: Displays the list of rules for the activity.
- ipnat-c-F: reinitialization of the rules table.
- map em0 192.168.1.0/24, 195.221.227.57/32 em0: maps an IP address to an interface.
- Map em0 192.168.1.0/24-195.221.227.57/32 portmap tcp/udp 20000:50000: mapping with port number.
- ipf-f file_name: writes the filter rule to the file.
- ipf-f -A: Resets the rules table.
- ipfstat-i: lists the active status entries when combined with the-s option (LCTT: The original is in doubt).
Hopefully this basic Linux Network command collection is useful and welcomes various questions and suggestions.
This article was reproduced from: http://www.linuxprobe.com/linux-network-command.html
Free to provide the latest Linux technology tutorials Books, for open-source technology enthusiasts to do more and better: http://www.linuxprobe.com/
Basic Linux Network command, you deserve to have