Linux Network configuration commands (i)--ifconfig ifconfig
View and configure network card information. Deprecated, using IP commands is recommended
Format:
Ifconfig [interface] To view specified NIC information, do not specify
Ifconfig interface [Aftype] options | Address ... Setting the specified NIC information
Options
Interface NIC Name
Up activates the NIC
Down network card
[-]arp allows/disables the use of the ARP protocol
[-]promisc allows/disables promiscuous mode, and if allowed, the network card will receive all packets packet
Example
- viewing network card information
IFCONIFG # View all network cards in use
Ifconfig–a # View all network cards
Ifconfig eth0 # View information for eth0 NIC
2. Setting Network card information
Ifconfig eth0 172.16.0.50/24 Up # Sets the IP and subnet mask of the NIC Eth0 and immediately opens
Ifconfig eth1 168.10.0.6 netmask 255.255.0.0 #设置网卡eth1的信息
Netstate
View information such as network connections, routing tables, network card data, spoofing connections, and multicast members
--route,-R View routing information
-T,--tcp view connection information related to TCP protocol
-U,--UDP
-L,--listen-ing view connection information in the listening state
-A,--all view all connection information
-N Displays IP and port information in numeric format
Example
View routing table information
Netstat-rn
View the network card bundle and accept packet data
[[Email protected] ~] #netstat-I
Kernel Interface Table
Iface MTU Met rx-ok rx-err rx-drp rx-ovr tx-ok tx-err tx-drp TX-OVR FLG
Eth0 0 294166 0 0 0 5889 0 0 0 Bmru
Eth1 0 646 0 0 0 1165 0 0 0 Bmru
Lo 65536 0 202 0 0 0 202 0 0 0 LRU
View TCP-related connections
Netstat–tan
Viewing UDP-related connections
Netstat–uan
To view a TCP connection in the listening state
Netstat-tnl
Route
View, set the routing table. This command is obsolete and it is recommended to use IP route
Format
Route [-cfvnee]
Route Add [-net |-host] target[netmask NM] [GW GW] # Add routing Records
Route del [-net |-host] TARGET [GW GW] [netmask Nm] [[Dev] If] # Delete route record
Options
-net represents network routing
-host indicates host routing
Target refers to a specific IP
Netmask refers to the subnet mask
GW Gateway
Dev refers to a specific NIC
Example
View the routing table
Route-rn
Add a route to the destination network address 11.11.0.0/16, via the gateway 172.16.0.1
Route add-net 11.11.0.0/16 GW 172.16.0.1
Set default gateway to 172.16.0.1
Route add–net 0.0.0.0 netmask 0.0.0.0 GW 172.16.0.1
Delete previous route record
Route Del-net 11.11.0.0/16
Linux Network Configuration Command (i)--ifconfig