In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
I. Network configuration commands:
1. Ifconfig (configure network interface command)
Command format: ifconfig [interface]
Ifconfig interface [aftype] options | address...
Examples of commands:
# View the configuration information of all Nic interfaces: ifconfig [- a]
~] # ifconfig
# View the interface configuration information of a network card: ifconfig IFACE
~] # ifconfig eth0
# enable or disable an ENI interface: ifconfig IFACE [up | down]
~] # ifconfig eth0 down
# configure the IP address of the Nic interface:
Ifconfig IFACE IP/mask [up] / ifconfig IFACE IP netmask MASK
~] # ifconfig eth0:0 1.1.1.1 Compact 32 up
# enable or disable Nic promiscuous mode: ifconfig IFACE [-] promisc
~] # ifconfig eth0-promisc # disabled
2. Route (routing management command)
Command format: route [- CFvnee]
Route add/del [- net |-host] target [netmask Nm] [gw Gw] [metric N] [[dev] If]
Command usage:
# View:
~] # route-n
# add:
~] # route add-host 192.168.1.3 gw 172.16.0.1 dev eth0 # Host Route ~] # route add-net 192.168.0.0 netmask 255.255.255.0 gw 172.16.0.1 dev eth0 # Segment Route ~] # route add-net 192.168.0.0and24 gw 172.16.0.1 dev eth0 # Segment Route ~] # route add default gw 172.16.0.1 # default Route
# Delete:
~] # route del dev eth0 ~] # route del-host 192.168.1.3 ~] # route del-net 192.168.0.0 netmask 255.255.255.0
3. Specify the DNS server
Configuration file: / etc/resolv.conf
Add:
Nameserver DNS_SERVER_IP1
Nameserver DNS_SERVER_IP2
Nameserver DNS_SERVER_IP3
4. Netstat (network connection status display command)
Command format: netstat [OPTION]
Option:-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 (display User and Inode)
-p: displays related processes and PID
Common combinations:
-tan.-uan.-tnl.-unl.
Display the routing table:
Netstat {--route |-r} [--numeric |-n]
-r: displays the kernel routing table (display)
-n: numeric format
-e: extended format (display Metric)
Display interface statistics:
Netstat {--interfaces |-I |-I} [iface] [--all |-a] [--extend |-e]
[--program |-p] [--numeric |-n]
# display statistics for all interfaces: netstat-I
~] # netstat-I
# display statistics for a specific interface: netstat-IIFACE
~] # netstat-Ieth0
Common status of TCP:
LISTEN: monitoring
ESTABLISHED: established connection
FIN_WAIT_1: active shutdown. A shutdown request has been issued, waiting for confirmation.
FIN_WAIT_2: active shutdown. You have received confirmation from the other party to close the transmission connection, waiting for the other party to send a request to close the connection.
SYN_SENT: send a SYN request and wait for the other party to confirm
SYN_RECV: a transfer request has been received but has not been confirmed yet
CLOSED: connection closed statu
5. Ss (network connection status display command, similar to netstat, more flexible and faster)
Format: ss [OPTION]... [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]
EXPRESSION:
Dport =
Sport =
~] # ss-o state established'(dport =: ssh or sport =: ssh)'
Common combinations:
-tan.-tanl.-tanlp.-uan.
Second, configure Linux network properties: ip command
Command format: ip [OPTIONS] OBJECT {COMMAND | help}
OBJECT: = {link | addr | route}
Link: network device attribute management
# display API attributes: ip link show [DEVICE] [up | down]
~] # ip link show eth0 ~] # ip link show up # shows the active interface
# set API attributes:
Ip link set DEVICE [{up | down} | [mtu MTU] | [promisc {on | off}]]
~] # ip link set eth0 up mtu 1500 promisc on
Addr:IP address management
Ip addr {add | del} IFADDR dev STRING
IFADDR available options:
[label LABEL]: indicates the alias of the network card when adding an address
[scope {global | link | host}]: indicates the scope (global: available globally, link: available only for links; host: available locally)
[broadcast ADDRESS]: indicates the broadcast address
# add IP
~] # ip addr add label eth0:0 2.2.2.2 Compact 24 dev eth0
# Delete IP
~] # ip addr del label eth0:0 2.2.2.2 Compact 24 dev eth0
Ip addr {show | flush} [dev DEVICE] [label PATTERN] [primary and secondary]
# display specified device IP information
~] # ip addr show label eth0:0 dev eth0 # displays IP information of Nic device aliases
# clear the IP information of the specified device
~] # ip addr show label eth0:0 dev eth0
Route: route management
Ip route {add | del | change} TARGET via GW dev IFACE src SOURCE_IP
TARGET: host routing: IP; Network routing: NETWORK/MASK
# add Host Route
~] # ip route 1.1.1.1 via 192.168.52.2 dev eth0
# add IP address range routing
~] # ip route add 2.2.2.0 dev eth0 src 24 via 192.168.52.2 dev eth0 src 192.168.52.20 # src specify the source IP
# add Gateway
~] # ip route add default via GW dev IFACE
# deleting a route:
~] # ip route del 1.1.1.1 via 192.168.52.2 dev eth0
# display routing information: ip route show
# clear the route list of specified devices: ip route flush dev IFACE
III. Linux network attribute configuration: modify the configuration file
IP, MASK, GW, DNS related configuration files:
/ etc/sysconfig/network-scripts/ifcfg-IFACE
Routing-related configuration files:
/ etc/sysconfig/network-scripts/route-IFACE
1. Set the interface parameters of the network card
/ etc/sysconfig/network-scripts/ifcfg-IFACE:
DEVICE: the device to which this profile is applied
HWADDR: the MAC address of the corresponding device
BOOTPROTO: address configuration protocol used to activate this device, commonly used dhcp, static, none, bootp
NM_CONTROLLED:NM is the abbreviation of NetworkManager; whether this Nic is controlled by NM; CentOS6 is recommended as "no"
ONBOOT: whether to activate this device when the system boots
TYPE: interface type; common Ethernet, Bridge
UUID: unique identification of the device
IPADDR: indicates the IP address
NETMASK: subnet mask
GATEWAY: default gateway
DNS1: the first DNS server points to
DNS2: the second DNS server points to
USERCTL: whether the average user can control this device
PEERDNS: if the value of BOOTPROTO is "dhcp", whether to allow the dns server assigned by dhcp server to point to information to directly override
To / etc/resolv.conf file
2. Define routes in the configuration file
Configuration file: / etc/sysconfig/network-scripts/route-IFACE
Two styles:
(1) TARGET via GW
(2) define one route every three lines
ADDRESS#=TARGET
NETMASK#=mask
GATEWAY#=GW
3. Configure the network card with multiple addresses:
(1) ifconfig: ifconfig IFACE_ALIAS
(2) ip:ip addr add
(3) configuration file: ifcfg-IFACE_ALIAS
DEVICE=IFACE_ALIAS
Note: gateway aliases cannot be booted using dhcp protocol
4. Tui (text user interface) configured with Linux network attributes
Command: system-config-network-tui or setup
Note: remember to restart the network service to take effect
5. Configure the hostname of the current host
Temporary effect: hostname [HOSTNAME]
Permanently effective: / etc/sysconfig/network
Add: HOSTNAME= your hostname
6. The network interface identifies and names the relevant udev configuration files:
/ etc/udev/rules.d/70-persistent-net.rules
Uninstall the Nic driver: modprobe-r e1000
Load the network card driver: modprobe E1000
IV. CentOS 7 network attribute configuration
(1) Nic naming mechanism
How systemd names network devices:
(a) if the index information provided by Firmware or BIOS for devices integrated on the motherboard is available and predictable, it is named after this index, such as eno1
(B) if the index information provided by Firmware or BIOS for the PCI-E expansion slot is available and predictable, name it according to this index, such as ens1
(C) if physical location information for the hardware interface is available, name it based on this information, such as enp2s0
(d) if the user starts it explicitly, it can also be named after the MAC address, enx2387a1dc56
(e) if none of the above is available, the traditional naming mechanism is used.
Some of the above naming mechanisms require the participation of biosdevname programs.
(2) the format of name composition
En: ethernet
Wl: wlan
Ww: wwan
Name type:
O: the device index number of the integrated device
S: the index number of the expansion slot
X: naming based on MAC address
Ps: enp2s1
(3) naming process of network card devices:
Step one:
Udev, accessibility program / lib/udev/rename_device, / usr/lib/udev/rules.d/60-net.rules
Step 2:
Biosdevname will be based on / usr/lib/udev/rules.d/71-biosdevname.rules
Step 3:
By detecting the network interface device, according to / usr/lib/udev/rules.d/75-net-description
ID_NET_NAME_ONBOARD, ID_NET_NAME_SLOT, ID_NET_NAME_PATH
Return to the traditional naming method:
Step one:
Edit / etc/default/grub configuration file
GRUB_CMDLINE_LINUX= "net.ifnames=0 rhgb quiet"
Step 2:
Generate its configuration file for grub2
Grub2-mkconfig-o / etc/grub2.cfg
Step 3:
Restart the system
(4) address configuration tool: nmcli
Nmcli [OPTIONS] OBJECT {COMMAND | help}
How to modify attributes such as IP address:
Usage: nmcli connection modify IFACE [+ | -] setting.property value
Setting.property:
Ipv4.addresses
Ipv4.gateway
Ipv4.dns1
Ipv4.method
# modify IP: [root@centos7 ~] # nmcli con modify eth0 ipv4.addresses 192.168.52.7 nmcli con modify eth0 24 # add IP: [root @ centos7 ~] # nmcli con modify eth0 + ipv4.addresses 1.1.1.1 IP: [root@centos7 ~] # nmcli con modify eth0-ipv4.addresses 1.1.1.1 IP: [root@centos7 ~] # nmcli con modify eth0 ipv4.gateway 192.168.52.modify DNS [root@centos7 ~] # nmcli con modify eth0 ipv4.dns 8.8.8.8
All the above editing operations need to be restarted to take effect:
[root@centos7 ~] # nmcli con down eth0;nmcli con up eth0 # restart takes effect
Usage: nmcli device {COMMAND | help}
COMMAND: = {status | show | connect | disconnect | delete | wifi}
Status: displays the status of all interfaces
Show []: displays the details of the specified interface
Connect: connect to the specified interface
Disconnect: disconnects the specified interface
Delete: deletes the specified interface
[root@centos7 ~] # nmcli dev show eth0GENERAL.DEVICE: eth0GENERAL.TYPE: ethernetGENERAL.HWADDR: 00:0C:29:01:DC:01GENERAL.MTU: 1500GENERAL.STATE: 100 (connected) GENERAL.CONNECTION: Eth0GENERAL.CON-PATH: / org/freedesktop/NetworkManager/ActiveConnection/4WIRED-PROPERTIES.CARRIER: onIP4.ADDRESS [1]: 192.168.52.7/24IP4.GATEWAY: 192.168.52.2IP6.ADDRESS [1]: fe80::20c:29ff:fe01:dc01/64IP6.GATEWAY:
(5) tui tool for network interface configuration: nmtui
[root@centos7 ~] # nmtui
(6) Host name configuration tool: hostnamectl {status | set-hostname}
[root@centos7 ~] # hostnamectl status Static hostname: localhost.localdomain Icon name: computer Chassis: n Machine ID:800b1ae9531f4c38964ddd3322f4624b Boot ID:ec6a5610e3444e668bed2c81bc981a5d Virtualization a Machine ID:800b1ae9531f4c38964ddd3322f4624b Boot ID:ec6a5610e3444e668bed2c81bc981a5d Virtualization: vmware Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-229.el7.x86_64 Architecture: x86 * 64 [root@centos7 ~] # hostnamectl set-hostname Centos7 # takes effect permanently
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.