In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
Common network management commands in network configuration rhel/Centos: setting ip basic information related configuration files
Version 5: system-config-network (setup)
Configuration file location: / etc/sysconfig/network-scripts/ifcfg-eth [0murn]
Version 7: nmcil nmtui (graphical interface)
Configuration file location: / etc/sysconfig/network-scripts/ifcfg-en*
Ifcfg-eth0,ifcfg-en* Network profile Information
TYPE=Ethernet # interface type is Ethernet card
BOOTPROTO=none # access address Protocol dhcp (automatic acquisition), static (manual configuration), none
HWADDR=00:0C:29:75:A1:89 # Network Card MAC
UUID=be9d332f-ae79-42b6-8040-d2d431e4e195 # network card identification
# DEVICE=eno16777736 # 7 series Nic name
The name of the network card of DEVICE=eth0 # 5jue 6 series
ONBOOT=yes # automatically activates the network card when booting, but no does not activate
IPADDR=10.76.249.91
GATEWAY=10.76.249.2
NETMASK=255.255.255.0
DNS=8.8.4.4
Configure IP addr
Add IP address temporarily and expire after restart
Ip addr add 192.168.1.150/24 dev eth0
Or
# ifconfig eth0 192.168.1.150 up # will fail after restart. The first Nic is eth0, the second is eth2, and so on.
# ifconfig
Eth0 1.1 Link encap:Ethernet HWaddr 00:0C:29:75:A1:89
Inet addr:192.168.1.150 Bcast:192.168.1.255 Mask:255.255.255.0
Inet6 addr: fe80::20c:29ff:fe75:a189/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5682 errors:0 dropped:0 overruns:0 frame:0
TX packets:4136 errors:0 dropped:0 overruns:0 carrier:0
Collisions:0 txqueuelen:1000
RX bytes:412252 (402.5 KiB) TX bytes:4464715 (4.2 MiB)
Configure default rout
# ip route add default via 192.168.1.1
# default via 192.168.1.1 devinterface
Check the relevant status of the network card 1. View IP
# ip addr show
1: lo: mtu 65536 disc noqueue state UNKNOWN
Link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
Inet 127.0.0.1/8 scope host lo
Valid_lft forever preferred_lft forever
Inet6:: 1/128 scope host
Valid_lft forever preferred_lft forever
2: eno16777736: mtu 1500 qdisc pfifo_fast state UP qlen 1000
Link/ether 200:0c:29:e1:c5:8a brd ff:ff:ff:ff:ff:ff
Inet 310.76.249.91/24 brd 10.76.249.255 scope global eno16777736
Valid_lft forever preferred_lft forever
Inet6 fe80::20c:29ff:fee1:c58a/64 scope link
Valid_lft forever preferred_lft forever
1: the network card status has been started
2: the mac address of the network card
3: the "eno16777736" address of the network card
Or
# ifconfig
Eth0 Link encap:Ethernet HWaddr 00:0C:29:75:A1:89
Inet addr:192.168.1.150 Bcast:192.168.1.255 Mask:255.255.255.0
Inet6 addr: fe80::20c:29ff:fe75:a189/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6386 errors:0 dropped:0 overruns:0 frame:0
TX packets:4436 errors:0 dropped:0 overruns:0 carrier:0
Collisions:0 txqueuelen:1000
RX bytes:467110 (456.1 KiB) TX bytes:4502451 (4.2 MiB)
Lo Link encap:Local Loopback
Inet addr:127.0.0.1 Mask:255.0.0.0
Inet6 addr: 1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:66 errors:0 dropped:0 overruns:0 frame:0
TX packets:66 errors:0 dropped:0 overruns:0 carrier:0
Collisions:0 txqueuelen:0
RX bytes:3482 (3.4 KiB) TX bytes:3482 (3.4 KiB)
Or
# nmcli dev show eth0
GENERAL. Equipment: eth0
GENERAL. Type: ethernet
GENERAL. Hard disk: 00:0C:29:E1:C5:8A
GENERAL.MTU: 1500
GENERAL. Status: 100 (connected)
GENERAL.CONNECTION: eno16777736
GENERAL.CON-PATH: / org/freedesktop/NetworkManager/ActiveConnection/1
WIRED-PROPERTIES. Containers: opening
IP4. Address [1]: 10.76.249.91 Universe 24
IP4. Gateway: 10.76.249.2
IP6. Address [1]: fe80::20c:29ff:fee1:c58a/64
IP6. Gateway:
two。 Check the status of sending and receiving packets
# ip-s link show eth0
2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
Link/ether 00:0c:29:75:a1:89 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
477844 6528 0 0 0
TX: bytes packets errors dropped carrier collsns
4508951 4492 0 0 0
Or
# ifconfig-s eth0
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
Eth0 1500 0 6459 00 0 4455 00 0 BMRU
3. Display displays the host default route
# ip route
Default via 10.76.249.2 dev eth0 proto static metric 100
10.76.249.0/24 dev eth0 proto kernel scope link src 10.76.249.91 metric 100
4. Show connection status
Commonly used options
Ss and netstat are used similarly, but ss is more efficient and consumes less performance.
Option
Function
-l
Connection in listening statu
-n
The service name is displayed as a number without parsing
-t
Show TCP connection
-u
Show UDP connection
-a
Show all statu
-p
Displays the connection initiated by which process
Common combinations
-tan,-tanl.-tanlp.-uan.
Several kinds of status information
State: LISTEN (monitoring), ESTAB (established link)
# ss-tna
State Recv-Q Send-Q Local Address:Port local port Peer Address:Port client port
LISTEN 0 128:: 22: *
LISTEN 0 128 *: 22 *: *
LISTEN 0 128 127.0.0.1 purl 6010 *: *
LISTEN 0 128:: 1 6010::
LISTEN 0 128 127.0.0.1 purl 6011 *: *
LISTEN 0 128:: 1 6011:: *
LISTEN 0 128 127.0.0.1 purl 6012 *: *
LISTEN 0 128:: 1 6012:: *
LISTEN 0 128 127.0.0.1 purl 6013 *: *
LISTEN 0 128:: 1 6013:: *
ESTAB 0 0 192.168.1.106:22 192.168.1.103:63167
ESTAB 0 0 192.168.1.150:22 192.168.1.103:63753
ESTAB 0 52 192.168.1.150:22 192.168.1.103:54953
ESTAB 0 0 192.168.1.106:22 192.168.1.103:63134
Centos/Redhat 7 Series returns to traditional Nic naming
Modify the contents of the network card file
# cat / etc/sysconfig/network-scripts/ifcfg- eno16777736
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
NAME=eno16777736
UUID=be9d332f-ae79-42b6-8040-d2d431e4e195
# DEVICE=eno16777736 # comment out the original name
DEVICE=eth0 # traditional naming
ONBOOT=yes
IPADDR=10.76.249.91
GATEWAY=10.76.249.2
NETMASK=255.255.255.0
Rename the network card file
# mv / etc/sysconfig/network-scripts/ifcfg-eno16777736 / etc/sysconfig/network-scripts/ifcfg-eth0
Edit / etc/default/grub configuration file
# vim / etc/default/grub
GRUB_TIMEOUT=5
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT= "console"
# GRUB_CMDLINE_LINUX= "rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet" # before modification
GRUB_CMDLINE_LINUX= "net.ifnames=0 rhgb quiet" # modified
GRUB_DISABLE_RECOVERY= "true"
Generate its configuration file for grub2
# grub2-mkconfig-o / etc/grub2.cfg
Generating grub configuration file...
Found linux p_w_picpath: / boot/vmlinuz-3.10.0-229.el7.x86_64
Found initrd p_w_picpath: / boot/initramfs-3.10.0-229.el7.x86_64.img
Found linux p_w_picpath: / boot/vmlinuz-0-rescue-16de415bcbd643d886010c2fe954d9cb
Found initrd p_w_picpath: / boot/initramfs-0-rescue-16de415bcbd643d886010c2fe954d9cb.img
Done
Restart the system
Verification result
# ip addr show eth0
2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
Link/ether 00:0c:29:e1:c5:8a brd ff:ff:ff:ff:ff:ff
Inet 10.76.249.91/24 brd 10.76.249.255 scope global eth0
Valid_lft forever preferred_lft forever
Inet6 fe80::20c:29ff:fee1:c58a/64 scope link
Valid_lft forever preferred_lft forever
Nmcli
Nmcli: network management command line interface: NetworkManagerCommand-Line Interface
Nmtui: network management text user interface: NetworkManager Text-User Interface
Network configuration commands after RHEL7
[root@localhost conf.d] # nmcli-- help
Usage: nmcli [OPTIONS] OBJECT {COMMAND | help}
OPTIONS
-t [erse] terse output
-p [retty] pretty output
-m [ode] tabular | multiline output mode
-f [ields] | all | common specify fields to output
-e [scape] yes | no escape columns separators in values
-n [ocheck] don't check nmcli and NetworkManager versions
-a [sk] ask for missing parameters
-w [ait] set timeout waiting for finishing operations
-v [ersion] show program version
-h [elp] print this help
OBJECT
G [eneral] NetworkManager's general status and operations
N [etworking] overall networking control
R [adio] NetworkManager radio switches
C [onnection] NetworkManager's connections is abbreviated to c
D [evice] devices managed by NetworkManager abbreviated as d
A [gent] NetworkManager secret agent or polkit agent
Reload the network configuration file
[root@localhost ~] # nmcli c reload
[root@localhost ~] # nmcli c load/etc/sysconfig/network-scripts/ifcfg-eth0
Configure IP addr
[root@localhost ~] # nmcli con mod eno16777736 ipv4.addresses' 192.168.1.119 Universe 24'
Use the Nic name to view # nmcli con show
Configure DNS
[root@localhost ~] # nmcli con mod eno16777736 ipv4.dns' 8.8.4.4'
Configure the gateway
[root@localhost ~] # nmcli con mod eno16777736 ipv4.gateway '192.168.1.1'
Disable and enable the network card
[root@localhost ~] # nmcli dev dis eth0
Dis is disconnect
[root@localhost ~] # nmcli con up eth0
View relevant information
[root@localhost ~] # nmcli device status
DEVICE TYPE STATE CONNECTION
Eth0 ethernet connected eno16777736
Lo loopback unmanaged--
The nmtui graphical configuration interface is relatively simple.
[root@localhost ~] # nmtui
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.