Linux network card network configuration basics

The ifconfig command makes the Linux kernel aware of network interfaces such as software loopbacks and network cards so that Linux can use them. In addition to the usages described above, the ifconfig command is used to monitor and change the status of network interfaces, and can also take many command line parameters. The following is a general calling syntax of ifconfig:
#ifconfig interface [[-net|-host] address [parameters]]
where interface is the network interface name: address is the host name or IP address assigned to the specified interface. The hostnames used here are resolved to their peer IP addresses, this parameter is required. The -net and -host parameters tell ifconfig to use this address as a network number or a host address, respectively.
If the ifconfig command is only followed by the port device name, it will display the configuration of the port; if there is no parameter, the ifconfig command will display all the information of the interface configured so far; if the -a option is used, Then you can also display the currently inactive interfaces.
An ifconfig call that checks the Ethernet interface eth0 yields the following output:
#ifconfig eth0
eth0 Link encap 10Mbps Ethernet HWaddr 00:00:C0:90:B3:44
inet addr xxx.xxx.xxx.xxx Bcast xxx.xxx.xxx .255 Mask 255.255.255.0
UP BROADCAST RUNNING MTU 1500 Metric 0
RX packets 3136 errors 217 dropped 7 overrun 26
TX packets 1752 errors 25 dropped 0 overrun 0
(Note: where XXX.XXX.XXX.XXX is the IP address)
The MTU and Metric columns show the maximum data transmission value and interface metric value of the current eth0 interface. The interface metric represents the cost of sending a packet on this path. Routing is not currently used in the kernel, but may be in the future. The RX (packets received) and TX (packets transmitted) lines show the number of packets received and transmitted, as well as the number of packet errors, lost packets (one possible reason is low memory) and overruns (usually in Occurs when the receiver receives data faster than the core can process it).
Parameters represent the various parameters supported by ifconfig, and the status of the network interface can be easily monitored and changed by using these parameters.

Dachang senior operation and maintenance engineer Linux entry dry content

Dachang senior operation and maintenance engineer Linux basics introduction dry content

Introduction to Linux Basics and Enterprise Application Deployment Practice
The command line parameters of ifconfig:
up activates the specified interface
down closes the specified interface. This parameter can effectively prevent the IP information
flow through the specified interface. If we want to permanently close an interface, we also need to
delete all the routing information of the interface from the core routing table
. netmask mask Set the IP netmask for the interface. The mask can be a 32-bit hexadecimal
number prefixed with 0x, or 4 decimal numbers separated by dots. If you do not plan to subnet your network
, you can ignore this option; if you do, remember that
every system on the network must have the same subnet mask.
pointpoint Turns on point-to-point mode for the specified interface. It tells the kernel that the interface is
a direct connection to another machine. When an address is included, that address is assigned to
the machine at the other end of the list.
If no address is given, the POINTPOINT option is turned on for the specified interface . Add a minus sign in front to turn off the pointpoint option.
broadcast address When an address is used, sets the broadcast address of this interface. If
no address is given, the IFF_BROADCAST option is turned on for the specified interface.
Preceding it with a minus sign means to turn off this option.
metric number Sets the interface metric to the integer number.
The metric represents the cost of sending a packet on this path . Routing costs are not currently used in the kernel, but will be in the future.
mtu bytes sets the maximum number of bytes the interface can handle in one transfer to the integer bytes.
Currently the core networking code does not handle IP fragmentation, so be sure to
set the MTU (Maximum Data Transfer Unit) value high enough that
arp turns on or off the ARP protocol used on the specified interface. Preceded by a minus sign to
turn off the option.
allmuti Turns on indiscriminate mode for the specified interface. Turn on this mode to have the interface send all traffic on the network
to the core, not just your machine's traffic to
the core. Add a minus sign in front to turn off the option
hw Set the hardware address for the specified interface. The ASCII equivalent of the hardware type name and the secondary hardware address
must follow this keyword. Currently supports Ethernet
(ether), AMPR, AX.25 and PPP
traliers to turn on the tracer on Ethernet frames. Not yet implemented in LINUX networking

Usually not all of these configurations need to be used. Ifconfig can set everything you need from just the interface name, netmask and assigned IP address. When ifconfig misses or has a complex network, just reset most parameters.

Use netstat to check network status

The next section will introduce a useful command - netstat, using the netstat command to monitor TCP/IP network configuration and working conditions. It can display the kernel routing table,
active network status, and useful statistics for each network interface. See the man page for details.
-a displays information about all Internet connections, including those that are listening
-i displays statistics for all network devices
-c continuously displays the updated status of the network. This parameter uses netstat to output a list of network status once per second
until the program is interrupted
-n display remote address, local address and port information in numeric/raw form instead of resolving hostname
and server
-o display counter expiry time and back off for each network connection
-r display kernel routing table
-t only display TCP socket information, including the information being monitored
-u only display UDP socket information
-v display netstat version information
-w display original (raw) socket information
-x display UNIX domain socket information

Getting Started with Linux Basics

Linux from entry to actual project

Introduction to Linux Basics and Practice of Enterprise Application Deployment

Enterprise-level combat of Shell programming for Linux operation and maintenance

Guess you like

Origin blog.csdn.net/m0_37449634/article/details/131451153