In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
Common types of network cards
Lo (loopback): local loopback
EthNUM: Ethernet network card
PppNUM: point to point
EnsNUMs in CentOS7
=
Commands related to network configuration
1. Ifconfig (ifup,ifdown)
II. Route
III. Netstat
IV. Ip
5. Ss
VI. Tool for configuring network with graphical interface: system-config-network-tui
CentOS 7:
Command line mode: nmcli
Graphic mode: nmtui
=
Configuration files related to network configuration
/ etc/sysconfig/network-scripts/ifcfg-eth#
=
1. Ifconfig
The English full name of ifconfig is network interfaces configuring, and its function is to display or configure commands for network devices (network interfaces).
The usage of ifconfig:
Enable promiscuous mode: [-] all promisc; packets on this network will be received by this network device interface
1. Ifconfig-a
[root@centos6 ~] # ifconfig-a / / displays all Nic device information
Description:
Eth0 represents the first network card, where HWaddr represents the physical address of the network card. You can see that the physical address (MAC address) of this network card is 00:0C:29:C1:97:20.
Inet addr is used to represent the IP address of the network card. The IP address of this network card is 10.0.0.80, the broadcast address-Bcast:10.0.0.255, the mask address Mask:255.255.255.0
Lo is the bad address of the host, which is generally used to test a network program, but does not want users of the local area network or external network to view it, so it can only run and view the network interface used on this host.
First line: connection type: Ethernet (Ethernet) HWaddr (hardware mac address)
Second line: IP address, broadcast address, subnet mask of the network card
The third line: UP (representing the open status of the network card), RUNNING (the network cable representing the network card is connected), MULTICAST (supporting multicast), MTU:1500 (maximum transmission unit): 1500 bytes
Fourth and fifth elements: statistics of receiving and sending packets
Line 7: receive and send data byte statistics
2. Ifconfig interface [up | down] / / start or disable the interface
3. Ifconfig interface IP/mask / / set the ip address for the interface
4. Ifconfig interface-alias IP/mask / / set the ip address for the interface alias; effective immediately
[root@centos6 ~] # ifconfig eth0:0 172.16.100.5 Universe 16
5. Ifup, ifdown = start, disable
Usage: ifup | ifdown interface is equivalent to ifconfig interface up | down
II. Route--- routing management commands
-n display information about routes digitally
[root@centos6 ~] # route-n
Route [- net |-host] target [netmask Nm] [gw Gw] [[dev] If]
Options:
Add add
-host host routin
-net network routin
1. Example: add host route; destination: 192.168.1.10 gateway: 10.0.0.1
[root@centos6 ~] # route add-host 192.168.1.10 gw 10.0.0.1 dev eth0
The execution result is shown in the following figure:
U (route is up) routing enabled
H (target is a host) the target is the host
G (use gateway) uses gateway
2. Example: add a network route; destination: 192.168.0.0 gateway: 10.0.0.1
[root@centos6 ~] # route add-net 192.168.0 dev eth0 24 gw 10.0.0.1 dev eth0
3. Example: add a default route
[root@centos6 ~] # route add default gw 10.0.0.1
Del deletion
-host host routin
-net network routin
1. Example: delete host route; destination: 192.168.1.10 gateway: 10.0.0.1
[root@centos6] # route del-host 192.168.1.10
2. Example: delete network route; destination: 192.168.0.0 gateway: 10.0.0.1
[root@centos6] # route del-net 192.168.0.0 Universe 24
III. Netstat---- network status information
Netstat [--tcp |-t] [--udp |-- raw |-w] [--listening |-l] [--all |-a] [--numeric |-n] [--extend |-e [--extend |-e]] [--program |-p]
-t: related to tcp protocol
-u: related to udp protocol
-w: raw socket related
-l: in monitoring state
-a: all statu
-n: display IP and port in numbers
-e: extended format
-p: displays related processes and PID
Display the routing table:
Netstat {--route |-r} [--numeric |-n]
-r: displays the kernel routing table
-n: numeric format
Display interface statistics:
Netstat {--interfaces |-I |-I} [iface] [--all |-a] [--numeric |-n]
# netstat-I
# netstat-I [interface]
IV. Ip
Linux's ip command is similar to ifconfig, but the former is more powerful and is intended to replace the latter. With the ip command, you can easily perform some network management tasks with just one command.
Usage: ip [OPTIONS] OBJECT {COMMAND | help}
OBJECT: = {link | addr | route}
Ip link show-- display device Properties
[root@centos7 ~] # ip link show
Ip link set-- changes the properties of the device
[root@centos7 ~] # ip link set dev ens33 down / / disable the network card ens33 [root@centos7 ~] # ip link set dev ens33 up / / enable the network card ens33
Ip address show-- displays ip address
[root@centos7 ~] # ip addr show / / displays the ip address of the network card
Ip address add-- add a new ip address
[root@centos7 ~] # ip addr add 172.16.100.10 Universe 16 dev ens33
Ip address del-- deletes an ip address
[root@centos7 ~] # ip addr del 172.16.100.10 Universe 16 dev ens33
Ip address flush-- clears the ip address
[root@centos7 ~] # ip addr flush dev ens33 / / clear the ip address of the network card
Ip route show-- displays routes
[root@centos7 ~] # ip route show / / displays routing table information
Ip route add-add a new rout
[root@centos7 ~] # ip route add 172.16.100.2 via 192.168.1.1 / / add host route
[root@centos7 ~] # ip route add 172.16.0.0Plus 16 via 192.168.1.1 / / add a network route
Ip route delete-- delete route
[root@centos7 ~] # ip route del 172.16.100.2 / Delete Host Route [root@centos7 ~] # ip route del 172.16.0.0and16 / Delete Network Route
5. Ss
The ss command is used to display the socket status. It can display statistics such as PACKET sockets, TCP sockets, UDP sockets, DCCP sockets, RAW sockets, Unix domain sockets, etc. It displays more tcp and state information than other tools. It is a very practical, fast and effective new tool for tracking IP connections and sockets
Usage: ss [options] [FILTER]
Options:
-t: related to tcp protocol
-u: related to udp protocol
-w: bare socket related
-x:unix sock related
-l: connection with listen statu
-a: all
-n: numeric format
-p: related programs and PID
-e: extended information
-m: memory usage
-o: timer information
FILTER: = [state TCP-STATE] [EXPRESSION]
Common state status of ss:
Established
Syn-sent
Syn-recv
Fin-wait-1
Fin-wait-2
Time-wait
Closed
Close-wait
Last-ack
Listen
Closing
All: All of the above states
Connected: All the states except for listen and closed
Synchronized: All the connected states except for syn-sent
Bucket: Show states, which are maintained as minisockets, i.e. Time-wait and syn-recv.
Big: Opposite to bucket state.
Ss lists http and https connections in the FIN-WAIT-1 state
Ss-o state fin-wait-1'(sport =: http or sport =: https)'
Why is ss faster than netstat?
Netstat traverses every PID directory under / proc, and ss reads the statistics under / proc/net directly. So the execution of ss consumes much less resources and time than netstat!
VI. Tool for configuring network with graphical interface: system-config-network-tui
[root@centos6 ~] # yum install-y system-config-network-tui / / tools required for installation [root@centos6 ~] # system-config-network-tui / / run, as shown in the figure
It is important to note that it is easy to configure with this tool, and the contents of the configuration are saved directly to the / etc/sysconfig/network-scripts/ifcfg-eth0 file.
7. Cmcli, a command line tool for network configuration on Centos7
Command format:
Nmcli [OPTIONS] OBJECT {COMMAND | help}
In fact, the ip commands on nmcli and centos6 are very similar, with almost exactly the same format, but with different options and subcommands.
Subcommands and common options: subcommands can be abbreviated
Connection is abbreviated to: C or con
Show displays network card information
Modify sets Nic properties
The format of modify:
Modify IFACE [+ | -] setting.property value
Setting.property:ipv4.address | ipv4.gateway | ipv4.dns | ipv4.method (manual)
[root@centos7 ~] # nmcli c show / / display network card information NAME UUID TYPE DEVICE ens33 4a126337-4537-4462-a516-cd01d417e775 802-3-ethernet ens33 [root@centos7 ~] # nmcli c modify ens33 + ipv4.addresses 172.16.100.2 / / set a new ipv4 address for the network card
Device is abbreviated to d or dev
Status to view the status information of the network card
Show views the attribute information of the network card
[root@centos7 ~] # nmcli d show ens33
8. Graphic tools: nmtui
How to use it:
[root@centos7 ~] # nmtui
At this point, the introduction of network configuration commands or graphical configuration tools is complete!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.