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

Cloud Computing Learning Route course syllabus Courseware: the Foundation of Network Management

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

Share

Shulou(Shulou.com)06/03 Report--

Cloud Computing Learning Route course syllabus Courseware: the Foundation of Network Management

=

Network interface names

Traditionally, network interfaces in Linux are enumerated as eth0, eth2, eth3, and so on. However, the mechanism which

Sets these names can cause changes to which interface gets which name as devices are added and removed.

The default naming behavior in Red Hat Enterprise Linux 7 is to assign fixed names based on firmware, device topology

And device type.

Interface names have the following characters:

Ethernet interfaces begin with en, WLAN interfaces begin with wl, and WWAN interfaces begin with ww.

The next character (s) represents the type of adapter with an o for on-board, s for hotplug slot, and p for PCI geographic location.

Not used by default but also available to administrators, an x is used to incorporate a MAC address.

Finally, a number N is used to represent an index, ID, or port.

If the fixed name cannot be determined, the traditional names such as ethN will be used.

For example, the first embedded network interface may be named eno1 and a PCI card network interface may be named enp2s0.

The new names make it easier to distinguish the relationship between a port and its name if the user knows both, but the

Trade off is that users cannot assume a system with one interface calls that interface eth0.

Use NetworkManager to manage the network

The Network Manager (NetworkManager) is a dynamic network controller and configuration system that keeps devices and connections open and activated when network devices are available.

By default, CentOS/RHEL 7 has Network Manager installed and enabled.

Device devices, physical devices such as enp2s0,virbr0,team0

Connection connection. Logical setting refers to a set of specific configuration schemes.

Multiple connection can be applied to the same device, but only one connection can be enabled at a time.

The advantage is that for one network interface, you can set up multiple network connections, such as static IP and dynamic IP, and then up the corresponding connection as needed

Tools provided by NetworkManager

Nmcli, nmtui, nm-connect-editor

Method 1: modify ip/netmask/dns/gateway [understanding]

[root@tianyun ~] # nmcli connection add con-name enp2s0-auto autoconnect yes ifname enp2s0 type ethernet

[root@tianyun ~] # nmcli connection add con-name enp2s0-gun autoconnect yes ifname enp2s0 type ethernet ip4 10.10.10.10 take 24 gw4 10.10.10.254

[root@tianyun ~] # nmcli connection show enp2s0-auto | grep ipv4.me

Ipv4.method: auto

[root@tianyun ~] # nmcli connection show enp2s0-gun | grep ipv4.me

Ipv4.method: manual

[root@tianyun ~] # ls / etc/sysconfig/network-s/

Ifcfg-enp2s0 ifdown-ippp ifdown-TeamPort ifup-ipv6 ifup-Team

Ifcfg-enp2s0-auto ifdown-ipv6 ifdown-tunnel ifup-isdn ifup-TeamPort

Ifcfg-enp2s0-gun ifdown-isdn ifup ifup-plip ifup-tunnel

[root@tianyun ~] # nmcli connection up enp2s0-auto

[root@tianyun ~] # nmcli connection delete enp2s0-auto

[root@tianyun ~] # nmcli connection modify enp2s0-gun ipv4.method a

[root@tianyun ~] # nmcli connection modify enp2s0-gun ipv4.method m

[root@tianyun ~] # nmcli connection modify enp2s0-gun + ipv4.addresses 20.20.20.20 Universe 24

[root@tianyun] # nmcli connection modify enp2s0-gun + ipv4.dns 114.114.114.114

[root@tianyun ~] # nmcli connection show enp2s0-gun | grep ipv4.add

Ipv4.addresses: 10.10.10.10/24, 20.20.20.20/24

Method 2: modify ip/netmask/dns/gateway

[root@tianyun ~] # vim / etc/sysconfig/network-s/ifcfg-enp2s0

NAME= "enp2s0"

DEVICE= "enp2s0"

ONBOOT=yes

NETBOOT=yes

BOOTPROTO=none

IPADDR=172.16.120.246

PREFIX=24

IPADDR1=192.168.200.246

PREFIX1=24

GATEWAY=172.16.120.254

DNS1=8.8.8.8

DNS2=114.114.114.114

[root@tianyun ~] # nmcli con reload

[root@tianyun ~] # nmcli con down enp2s0; nmcli con up enp2s0

Note: delete self-built connection connection

Manage the network without using NetworkManager

Aliyun

[root@aliyun ~] # nmcli connection delete enp2s0-auto

[root@aliyun ~] # systemctl disable NetworkManager

[root@aliyun ~] # systemctl stop NetworkManager

[root@aliyun ~] # systemctl status NetworkManager

● NetworkManager.service-NetworkManager

Loaded: loaded (/ usr/lib/systemd/system/NetworkManager.service; disabled; vendor preset: enabled)

Active: inactive (dead)

[root@aliyun ~] # vim / etc/sysconfig/network-s/ifcfg-eth0

NAME=eth0

DEVICE=eth0

ONBOOT=yes

NETBOOT=yes

BOOTPROTO=none

IPADDR=192.168.122.169

PREFIX=24

TYPE=Ethernet

[root@aliyun ~] # systemctl restart network.service

The following configurations are independent of NetworkManager:

Modify hostname / etc/hostnamehostnamectl set-hostname tianyun.example.comcat / etc/hostnamereboot configuration name resolution Configuring name resolution

A. Hosts

[root@tianyun ~] # cat / etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6

119.75.218.70 www.baidu.com

[root@tianyun ~] # getent hosts www.baidu.com

119.75.218.70 www.baidu.com

B. Resolv.conf DNS

[root@tianyun ~] # cat / etc/resolv.conf

Generated by NetworkManager

Nameserver 114.114.114.114

[root@tianyun ~] # yum-y install bind-utils

[root@tianyun ~] # host www.sina.com

Www.sina.com is an alias for us.sina.com.cn.

Us.sina.com.cn is an alias for wwwus.sina.com.

Wwwus.sina.com has address 66.102.251.33

Basic network testing tools

[root@tianyun ~] # ip a

[root@tianyun ~] # ip a s eth0

[root@tianyun ~] # ip route

[root@tianyun ~] # ip neigh

[root@tianyun ~] # hostname

[root@tianyun ~] # ping www.baidu.com

[root@tianyun] # ping-c2 www.baidu.com

[root@tianyun ~] # ip-s link show eth0

[root@tianyun ~] # traceroute www.sina.com

[root@tianyun ~] # tracepath www.sina.com

1?: [LOCALHOST] pmtu 1500

1: no reply

2: 11.245.87.126 0.787ms

3: 106.11.130.218 0.387ms

4: 42.120.244.125 0.425ms

5: 150.138.132.157 1.469ms

6: 150.138.128.241 3.546ms asymm 7

7: 202.97.40.241 24.677ms

8: 202.97.24.154 14.197ms

9: 202.97.33.154 18.340ms asymm 10

10: 202.97.90.242 182.632ms

11: 203.14.186.138 193.383ms asymm 13

12: 218.30.41.234 209.543ms asymm 13

13: 66.102.251.33 163.224ms reached

Resume: pmtu 1500 hops 13 back 14

View the status of the physical connection of the device

[root@tianyun ~] # ip a

2: enp1s0: mtu 1500 qdisc pfifo_fast master br0 state DOWN qlen 1000

If the information above disabling ONBOOT=no on the connection is not true

[root@tianyun ~] # ethtool enp1s0

Link detected: no

Ports and services

The following is a sample service:

[root@aliyun ~] # yum-y install httpd vsftpd

[root@aliyun ~] # systemctl start httpd

[root@aliyun ~] # systemctl start vsftpd

Http 80/tcp

Https 443/tcp

Ssh 22/tcp

Ftp 21/tcp

Show TCP sockets (LISTEN)

[root@aliyun ~] # ss-tnl

State Recv-Q Send-Q Local Address:Port Peer Address:Port

LISTEN 0 128: 80: *

LISTEN 0 128: 8080: *

LISTEN 0 10 114.215.71.214:53:

LISTEN 0 10 10.29.89.165:53:

LISTEN 0 10 127.0.0.1:53:

LISTEN 0 128: 22: *

LISTEN 0 128 127.0.0.1:953:

LISTEN 0 128 127.0.0.1:6010:

LISTEN 0 128: 443: *

LISTEN 0 32:: 21: *

LISTEN 0 10:: 53: *

[root@aliyun ~] # ss-tnl | grep: 80

LISTEN 0 128: 80: *

[root@aliyun ~] # ss-tnl | grep: 21

LISTEN 0 32:: 21: *

[root@aliyun ~] # ss-atn

State Recv-Q Send-Q Local Address:Port Peer Address:Port

LISTEN 0 128: 80: *

LISTEN 0 10 114.215.71.214:53:

LISTEN 0 10 10.29.89.165:53:

LISTEN 0 10 127.0.0.1:53:

LISTEN 0 128: 22: *

LISTEN 0 128 127.0.0.1:953:

LISTEN 0 128 127.0.0.1:6010:

ESTAB 0 52 114.215.71.214:22 123.120.38.233:49603

ESTAB 0 0 114.215.71.214:40962 140.205.140.205:80

LISTEN 0 32:: 21: *

LISTEN 0 10:: 53: *

[root@aliyun ~] # ss-atn | grep: 22

LISTEN 0 128: 22: *

ESTAB 0 52 114.215.71.214:22 123.120.38.233:49603

[root@aliyun ~] # ss-atn | grep: 80

LISTEN 0 128: 80: *

ESTAB 0 0 114.215.71.214:40962 140.205.140.205:80

An all states, including LISTEN

Show UDP sockets (all states)

[alice@tianyun ~] $ss-anu

State Recv-Q Send-Q Local Address:Port Peer Address:Port

UNCONN 0 0 114.215.71.214:53:

UNCONN 0 0 10.29.89.165:53:

UNCONN 0 0 127.0.0.1:53:

UNCONN 0 0 114.215.71.214:123:

UNCONN 0 0 10.29.89.165:123:

UNCONN 0 0 127.0.0.1:123:

UNCONN 0 0: 123: *

UNCONN 0 0:: 53: *

UNCONN 0 0: 123: *

[kiosk@foundation0 ~] $ss-tan | grep: 5910

LISTEN 0 5: 5910: *

ESTAB 0 0 172.25.254.250:5910 172.25.254.44:51435

ESTAB 0 0 172.25.254.250:5910 172.25.254.6:40546

ESTAB 0 0 172.25.254.250:5910 172.25.254.18:37780

ESTAB 0 0 172.25.254.250:5910 172.25.254.13:55841

ESTAB 0 0 172.25.254.250:5910 172.25.254.35:36984

ESTAB 0 0 172.25.254.250:5910 172.25.254.9:47342

ESTAB 0 0 172.25.254.250:5910 172.25.254.2:40955

ESTAB 0 0 172.25.254.250:5910 172.25.254.12:50833

ESTAB 0 0 172.25.254.250:5910 172.25.254.36:50854

ESTAB 0 0 172.25.254.250:5910 172.25.254.1:52444

ESTAB 0 0 172.25.254.250:5910 172.25.254.47:39335

ESTAB 10 0 172.25.254.250:5910 172.25.254.14:55833

Temporarily configure network information

Ip/netmask

Ip addr add dev eth2 3.3.3.3/24ip addr del dev eth2 3.3.3.3/24

Gateway

Ip route del defaultip route add default via 192.168.122.3ip route add 10.10.10.0/24 via 192.168.122.5

Hostname

Hostname tianyun.cc.com

Configuration file:

# vim / etc/sysconfig/network-s/ifcfg-eth0

DEVICE=eth0 device name

[NAME= "System eth0" device name] may not exist

BOOTPROTO=none Startup Protocol how to obtain ip address static, none = = > static access to dhcp dynamic

NM_CONTROLLED=no defaults to yes to turn off network-manager

ONBOOT=yes boot up

TYPE=Ethernet Ethernet Typ

HWADDR=00:0c:29:8e:a5:d3 mac address

IPADDR=172.16.80.252 ip address

NETMASK=255.255.0.0 mask

PREFIX = 24

NETWORK=172.16.0.0

GATEWAY=172.16.80.1 Gateway

Dns domain name server domain name resolution

Help documentation:

# vim / usr/share/doc/inits-9.03.38/sysconfig.txt

Gateway: the level (exit) of the network, which is generally set to the router

IP forwarding:

Temporary

Echo 1 > / proc/sys/net/ipv4/ip_forward

Permanent

Vim / etc/sysctl.conf modifies kernel parameters

Net.ipv4.ip_forward = 1

Sysctl-p / / effective immediately

Dns: domain name server, one of which is to resolve domain names to Ip addresses

Dns profile (client)

# vim / etc/resolv.conf

Nameserver 172.16.70.250

View mac

# arping 172.16.70.250

Scan ip

# nmap-v-sP 172.16.70.0Unix 24

Scan port

# nmap-v-A 172.16.70.0Univer 24

Restart the network service:

# systemctl restart network / / rhel7

# / etc/init.d/network restart / / rhel5/6

# service network restart / / rhel5/6

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