Network commands for advanced Linux systems

Source: Internet
Author: User

Ifconfig

1. Role

 

Ifconfig is used to view and change network interface addresses and parameters, including IP addresses, network masks, and broadcast addresses. The user has the permission to use ifconfig.

 

2. Format

 

Ifconfig-interface [Options] address

3. Main Parameters

-Interface: Specifies the network interface name, such as eth0 and eth1.

Up: Activate the specified network interface card.

Down: Disable the specified network interface.

Broadcast address: Set the broadcast address of the API.

Pointopoint: enables point-to-point.

Address: Set the IP address of the specified interface device.

Netmask address: Set the subnet mask of the interface.

4. Application description

 

Ifconfig is a command line tool used to set and configure the NIC. To manually configure the network, this is a required command. The advantage of using this command is that you do not need to restart the machine. To assign the eth0 interface IP address 207.164.186.2 and activate it immediately, run the following command:

# Fconfig eth0 210.34.6.89 netmask 255.255.255.128 broadcast 210.34.6.127

 

Note:

This command is used to set the IP address, network mask, and local broadcast address of the network adapter eth0. If you run the ifconfig command without any parameters, the command displays information about all the machine's activation interfaces. The command with the "-a" parameter displays information about all interfaces, including interfaces that are not activated. Note that network device parameters configured using the ifconfig command will be lost after the machine is restarted.

To pause a network interface, you can use the down parameter:

# Ifconfig eth0 down

 

Ping

1. Role

Ping checks the network interface status of the host. the permission is granted to all users.

2. Format

Ping [-dfnqrrv] [-C] [-I] [-I] [-L] [-p] [-S] [-T] IP Address

3. Main Parameters

-D: Use the socket so_debug function.

-C: set the number of requests to respond.

-F: limit detection.

-I: specifies the number of seconds between sending and receiving information.

-I: the network interface uses the specified network interface to send data packets.

-L: The data packet that is sent before the request information is sent.

-N: only numbers are output.

-P: set the pattern for filling data packets.

-Q: The command execution process is not displayed, except for information related to the beginning and end.

-R: ignore common routing tables and directly send data packets to the remote host.

-R: records the routing process.

-S: Set the packet size.

-T: Set the TTL value.

-V: displays the instruction execution process in detail.

Note:

The Ping Command is the most commonly used network command. We usually use it to check whether the network is connected. It uses the ICMP protocol. However, sometimes we can view a web page in the browser, but we cannot ping it because some websites are in security consideration and have installed the firewall. In addition, you can try it on your computer and use the following method to make the system do not respond to Ping:

# Echo 1>/proc/sys/NET/IPv4/icmp_echo_ignore_all

Netstat

1. Role

Check the network status of Linux.

2. Format

Netstat [-accefghilmnnoprstuvvwx] [-A] [-- IP]

3. Main Parameters

-A -- all: displays the sockets in all connections.

-A: List the IP address and network type of the network connection.

-C -- continuous: continuously lists the network status.

-C -- cache: displays the cache information of the vro configuration.

-E -- Extend: displays other network-related information.

-F -- fib: displays fib.

-G -- groups: displays a list of members of multiple broadcast groups.

-H -- help: online help.

-I -- interfaces: displays the network interface information form.

-L -- listening: displays the socket of the monitored server.

-M -- masquerade: displays disguised network connections.

-N -- numeric: the IP address is used directly instead of the Domain Name Server.

-N -- Netlink -- symbolic: displays the symbolic connection name of the network hardware peripheral device.

-O -- Timers: display the timer.

-P -- Programs: displays the program identification code and program name using the socket.

-R -- route: displays the routing table.

-S -- statistice: displays a statistical table of network work information.

-T -- TCP: displays the connection status of the TCP transmission protocol.

-U -- UDP: displays the connection status of the UDP transmission protocol.

-V -- verbose: displays the command execution process.

-V -- version: displays the version information.

-W -- raw: displays the connection status of the raw transmission protocol.

-X -- Unix: it is the same as the specified "-a Unix" parameter.

-- IP -- Inet: it is the same as the specified "-A Inet" parameter.

4. Application Instance

Netstat is mainly used for Linux to view its own network conditions, such as the opened port, the user services, and the service status. It also displays the system route table and network interface status. It can be said that it is a comprehensive network status inspection tool. By default, netstat only displays the ports with established connections. To display all listening ports, use the-a parameter:

# Netstat-

Active Internet connections (only servers)

PROTO Recv-Q send-Q local address foreign address State

TCP 0 0 *: 32768 *: * listen

TCP 0 0 *: 32769 *: * listen

TCP 0 0 *: NFS *: * listen

TCP 0 0 *: 32770 *: * listen

TCP 0 0 *: 868 *: * listen

TCP 0 0 *: 617 *: * listen

TCP 0 0 *: MySQL *: * listen

TCP 0 0 *: NetBIOS-SSN *: * listen

TCP 0 0 *: SunRPC *: * listen

TCP 0 0 *: 10000 *: * listen

TCP 0 0 *: HTTP *: * listen

......

As shown above, this host provides HTTP, FTP, NFS, MySQL, and other services at the same time.

TIPS:

1. bind multiple IP addresses to a network card

In Linux, you can use ifconfig to easily bind multiple IP addresses to one Nic. For example, if the original IP address of the eth0 interface is 192.168.0. 254, run the following command:

Ifconfig eth0: 0 192.168.0.253 netmask 255.255.255.0

Ifconfig eth0: 1 192.168.0.252 netmask 255.255.255.0

......

2. Modify the MAC address of the NIC

First, you must disable the NIC device. The command is as follows:

/Sbin/ifconfig eth0 down

Run the following command to modify the MAC address:

/Sbin/ifconfig eth0 HW ether 00: AA: BB: CC: DD: EE

Enable Nic again:

/Sbin/ifconfig eht0 up

The MAC address of the NIC is changed. The MAC address of each network adapter is unique, but cannot be modified. You only need to ensure the uniqueness of the MAC address in the network.

 

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.