Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the basic knowledge of network management in Linux operating system

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Linux operating system basic network management knowledge, many novices are not very clear, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

Network management

(1) View the network status

In Linux, ifconfig,route and netstat are often used to check the network status, which is. Net-tools tool, let me use it next.

I'm just talking about ifconfig and route.

There are many network card interfaces in our linux, such as eth0's first network card network interface, eno1 on-board "network card, ens33 PCI-E" network card. If CentOS 7 uses the "sex-causing" network device name, but none of the above matches, it will make eth0.

[root@node01 ~] # ifconfig eth0 eth0: error fetching interface information: Device not found [root@node01 ~] # ifconfig ens33 ens33: flags=4163 mtu 1500 inet 192.168.92.90 netmask 255.255.255.0 broadcast 192.168.92.255 inet6 fe80::b889:1772:c306:ef8f prefixlen 64 scopeid 0x20 ether 00:0c:29:07:43:5a txqueuelen 1000 (Ethernet) RX packets 910 bytes 954985 (932.6 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 450 bytes 38942 (38.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

(2) Network profile

Ifcfg-eth0,/etc/hosts

When configuring a hadoop,elasticsearch cluster, you need to configure the cluster IP and hostname in / etc/hosts. Sometimes you can't ping Baidu, maybe the domain name cannot be resolved, and you need to configure it in / etc/sysconfig/network-scripts/ifcfg-eth0.

[root@node01 ~] # vim / etc/sysconfig/network # HOSTNAME=node01 [root@node01 ~] # vim / etc/hosts # 192.168.92.90 node01 192.168.92.91 node02 192.168.92.92 node03 [root@node01 ~] # configure DNS, domain name resolution service [root@node01 ~] # vim / etc/sysconfig/network-scripts/ifcfg-eth0 DNS1=202.106.0.20 DNS2=8.8.8.8

(3) troubleshooting command

First, ping Baidu: check whether the network of the target machine is reachable.

Maoli@ubuntu:~$ ping baidu.com PING baidu.com (220.181.38.148) 56 (84) bytes of data. 64 bytes from 220.181.38.148: icmp_seq=1 ttl=128 time=49.6 ms 64 bytes from 220.181.38.148: icmp_seq=2 ttl=128 time=48.2 ms ^ C-baidu.com ping statistics-2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 48.223 ms 49.673 ms

Traceroute

Nslookup:nslookup www.baidu.com Server is the ip corresponding to the domain name.

Maoli@ubuntu:~$ nslookup www.baidu.com Server: 127.0.1.1 Address: 127.0.1.1: 53 Non-authoritative answer: www.baidu.com canonical name = www.a.shifen.com. Name: www.a.shifen.com Address: 182.61.200.6 Name: www.a.shifen.com Address: 182.61.200.7

Telnet: if the ip is reachable, but the service still has problems, you can check the service port status through telnet.

Tcpdump:tcpdump-I any-n port 80 # grabs all network card (any) port 80 packets and displays them in ip form (- n)

Maoli@ubuntu:~$ sudo tcpdump-I any-n port 80-n tcpdump: verbose output suppressed, use-v or-vv for full protocol decode listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes 10purge 28 tcpdump 11.003675 IP 192.168.92.1.53951 > 192.168.92.135.80: Flags [S], seq 185886164, win 64240, options [mss 1460 noprection wscale Length 0 10 seq 28 IP 11.003875 IP 192.168.92.135.80 > 192.168.92.1.53951: Flags [S.], seq 2863640054, ack 185886165, win 64240, options [mss 1460 Flags win 4114 IP 192.168.92.1.53951 > 192.168.92.135.80: Flags [.], ack 1, win 4106 Length 010: 28 seq 11.010472 IP 192.168.92.1.53951 > 192.168.92.135.80: Flags [P.], seq 1 Flags, ack 1, win 4106, length 475: HTTP: GET / sqli-labs/ HTTP/1.1

Tcpdump-I any-n host 10.0.0.1 and port 8 crawls packets between port 80 and 10.0.0.1 of all network cards and displays them in ip form

Netstat check whether the service listens to the port status correctly-n displays the ip address-t tcp protocol-p shows the process corresponding to the port-l tcp snooping status (listen)-ntpl to view the port opening

Maoli@ubuntu:~$ sudo netstat-ntlp activates Internet connection (server only) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0 Internet 22 0.0.0 0 LISTEN 1111/sshd tcp 0 0 127.0.1 .0.0.0: * LISTEN 14200/cupsd tcp 00 127.0.0.1 tcp 3306 0.0.0.0 LISTEN 1148/mysqld tcp 00 127.0.0.1 LISTEN 1165/redis-server 1 tcp 0 0 127.0.1.1 LISTEN 53 0.0.0.0 LISTEN 1285/dnsmasq tcp6 0: 22:: * LISTEN 1111/sshd tcp6 0 0:: * LISTEN 14200/cupsd tcp6 00: 9000: * LISTEN 2234/docker-proxy tcp6 00: 80: * LISTEN 1842/apache2

(4) Network service management

There are two kinds of network service management procedures, which are SysV and systemd. Now Systemd has basically replaced SysV's Init.

(5) set static ip

When building any cluster, you need to set up static ip.

[root@node01] # vim / etc/sysconfig/network-scripts/ifcfg-ens33 # BOOTPROTO=static ONBOOT= "yes" # Gateway address depends on the network of the system. Static ip IPADDR=192.168.92.92 NETMASK=255.255.255.0 # configuration DNS server DNS1=8.8.8.8 DNS2=8.8.4.4 set by GATEWAY=192.168.92.2 # is helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report