雲端計算學習路線教程大綱課件:網路管理基礎
雲端計算學習路線教程大綱課件:網路管理基礎
====================================================================================
Network interface names
Traditionally, network interfaces in Linux are enumerated as eth0, eth1, eth2, 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.
使用NetworkManager管理網路
網路管理器(NetworkManager)是一個動態網路的控制器與配置系統,它用於當網路裝置可用時保持裝置和連線開啟並啟用
預設情況下,CentOS/RHEL 7 已安裝網路管理器,並處於啟用狀態。
device 裝置,物理裝置 例如enp2s0,virbr0,team0
connection 連線,邏輯設定 指的是一套具體配置方案
多個connection可以應用到同一個device,但同一時間只能啟用其中一個connection。
這樣的好處是針對一個網路介面,可以設定多個網路連線,比如靜態IP和動態IP,再根據需要up相應的connection
NetworkManager提供的工具
nmcli, nmtui, nm-connect-editor
1. 方法一: 修改ip/netmask/dns/gateway[瞭解]
[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/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/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
2. 方法二:修改ip/netmask/dns/gateway
[root@tianyun ~]# vim /etc/sysconfig/network-s/ifcfg-enp2s0
NAME="enp2s0"
DEVICE="enp2s0"
>
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
注:刪除自建的連線connection
不使用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 - Network Manager
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
>
NETBOOT=yes
BOOTPROTO=none
IPADDR=192.168.122.169
PREFIX=24
TYPE=Ethernet
[root@aliyun ~]# systemctl restart network.service
以下配置跟NetworkManager無關:
1. 修改主機名/etc/hostname
# hostnamectl set-hostname tianyun.example.com
# cat /etc/hostname
# reboot
2. 配置名字解析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
[root@tianyun ~]# getent hosts
119.75.218.70
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
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
基本的網路測試工具
[root@tianyun ~]# ip a
[root@tianyun ~]# ip a s eth0
[root@tianyun ~]# ip route
[root@tianyun ~]# ip neigh
[root@tianyun ~]# hostname
[root@tianyun ~]# ping
[root@tianyun ~]# ping -c2
[root@tianyun ~]# ip -s link show eth0
[root@tianyun ~]# traceroute
[root@tianyun ~]# tracepath
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
檢視裝置物理連線的狀態
[root@tianyun ~]# ip a
2: enp1s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master br0 state DOWN qlen 1000
如果在連線禁用 以上的資訊不真實
[root@tianyun ~]# ethtool enp1s0
Link detected: no
ports and services
以下為示例服務:
[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
1. 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
a 所有狀態,包括 LISTEN
2. Show UDP sockets (所有狀態)
[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
臨時配置網路資訊
ip/netmask
# ip addr add dev eth1 3.3.3.3/24
# ip addr del dev eth1 3.3.3.3/24
gateway
# ip route del default
# ip route add default via 192.168.122.3
# ip route add 10.10.10.0/24 via 192.168.122.5
hostname
# hostname tianyun.cc.com
配置檔案:
#vim /etc/sysconfig/network-s/ifcfg-eth0
DEVICE=eth0 裝置名稱
【NAME="System eth0" 裝置名稱】 可以不存在
BOOTPROTO=none 啟動協議 獲取ip地址的方式 static、none ==>靜態獲取 dhcp 動態
NM_CONTROLLED=no 預設是yes 關閉network-manager
開機啟動
TYPE=Ethernet 乙太網型別
HWADDR=00:0c:29:8e:a5:d3 mac地址
IPADDR=172.16.80.252 ip地址
NETMASK=255.255.0.0 掩碼
PREFIX =24
NETWORK=172.16.0.0
GATEWAY=172.16.80.1 閘道器
dns domain name server 域名解析
幫助文件:
#vim /usr/share/doc/inits-9.03.38/sysconfig.txt
閘道器:網路的關卡(出口),一般設定到路由器上
IP轉發:
臨時
# echo 1 > /proc/sys/net/ipv4/ip_forward
永久
# vim /etc/sysctl.conf 修改核心引數
net.ipv4.ip_forward = 1
# sysctl -p //立即生效
dns : 域名伺服器,其中一種是解析域名到Ip地址
dns配置檔案(客戶端)
#vim /etc/resolv.conf
nameserver 172.16.70.250
檢視mac
#arping 172.16.70.250
掃描ip
#nmap -v -sP 172.16.70.0/24
掃描埠
#nmap -v -A 172.16.70.0/24
重啟網路服務:
#systemctl restart network //rhel7
#/etc/init.d/network restart //rhel5/6
#service network restart //rhel5/6
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69916964/viewspace-2659583/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 雲端計算學習路線教程大綱課件:LVM管理LVM
- 雲端計算學習路線教程大綱課件:FTP ServerFTPServer
- 雲端計算學習路線教程大綱課件:使用自建源
- 雲端計算學習路線教程大綱課件:關於NFSNFS
- 雲端計算學習路線教程大綱課件:部署網上商城ecshop
- 雲端計算學習路線教程大綱課件:交換分割槽管理 Swap
- 雲端計算學習路線教程大綱課件:使用RPM工具管理RPM包
- 雲端計算學習路線教程大綱課件:Linux新手入門教程Linux
- 雲端計算學習路線教程大綱課件:客戶端查詢客戶端
- 雲端計算學習路線教程大綱課件:磁碟陣列 RAID陣列AI
- 雲端計算學習路線教程大綱課件:檔案連結
- 雲端計算學習路線教程大綱課件:關於HTTP ServerHTTPServer
- 雲端計算學習路線教程大綱課件:部署網校系統 edusoho
- 雲端計算學習路線教程大綱課件:XFS檔案系統
- 雲端計算學習路線教程大綱課件:Mount 掛載詳解
- 雲端計算學習路線教程大綱課件:FAT檔案系統
- 雲端計算學習路線教程大綱課件:tCentos6網路卡問題CentOS
- 雲端計算學習路線教程大綱課件:雲端計算開發程式設計條件結構程式設計
- 雲端計算學習路線教程大綱課件:tar專案實戰案例
- 雲端計算學習路線教程大綱課件:HTTP Server: Apache知識點HTTPServerApache
- 雲端計算學習路線教程大綱課件:關於shell知識點
- 雲端計算學習路線教程大綱課件:部署部落格系統wordpress
- 雲端計算學習路線教程大綱課件:YUM 簽名檢查機制
- 雲端計算學習路線教程大綱課件:CentOS7修改網路卡為eth0CentOS
- 雲端計算學習路線課程大綱資料:儲存基礎知識
- 雲端計算學習路線教程大綱課件:EXT2/3/4檔案系統
- 好程式設計師雲端計算學習路線教程大綱課件:Mount掛載詳解程式設計師
- 雲端計算學習路線教程大綱課堂筆記:Apache訪問控制筆記Apache
- 雲端計算學習路線課程大綱資料:基本分割槽管理
- 雲端計算學習路線課程大綱資料:程式管道 Piping
- 雲端計算學習路線圖課件:多雲的管理方法
- 雲端計算學習路線課程大綱資料:作業控制 jobs
- 雲端計算學習路線課程大綱資料:檢視程式 process
- 雲端計算學習路線圖素材、課件,什麼是雲端計算的核心技術基礎?
- 雲端計算學習路線課程大綱資料:引數傳遞 Xargs
- 雲端計算學習路線課程大綱資料:檔案屬性 chattr
- 什麼叫做雲端計算?雲端計算基礎學習路線
- 雲端計算大資料學習路線課程大綱資料:hive入門操作大資料Hive