Linux学习 Unit 11

本文涉及的产品
公网NAT网关,每月750个小时 15CU
简介:

Unit11.管理网络


1.ip基础知识

1.ipv4

2进制32位-----10进制

 

172.25.0.10/255.255.255.0

172.25.0.10:ip地址

255.255.255.0:子网掩码

子网掩码255位对应的ip位为网络位

子网掩码0对应的ip位为主机位

 

2.配置ip

<<图形化>>

1.图形界面

nm-connection-editor

2.文本化图形

nmtui

 

<<命令>>

ifconfig 网卡 ip netmask                   ##临时设定

 

nmcli connection add type ethernet con-name westos ifname eth0 autoconnect yes

nmcli connection add type ethernet con-name westos ifname eth0 ip4 ip/24

nmcli connection delete westos

nmcli connection show

nmcli connection down westos

nmcli connection up westos

nmcli connection modify "westos" ipv4.addresses newip/24

nmcli connection modify "westos" ipv4.method <auto|manual>

nmcli device connect eth0

nmcli device disconnect eth0

nmcli device show

nmcli device status

 

 wKiom1jvL9zBfFtEAAAsHnXukkc884.jpg

 

<<文件>>

dhcp                                     ##动态获取

vim /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0                              ##接口使用设备

BOOTPROTO=dhcp                           ##网卡工作模式

ONBOOT=yes                               ##网络服务开启时自动激活

NAME=eth0                                ##网络接口名称

wq

systemctl restart network

 

 

 

static|none                              ##静态网络

vim /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0                              ##设备

BOOTPROTO=static|none                    ##设备工作方式

ONBOOT=yes                               ##开启网络服务激活设备

NAME=eth0                                ##网络接口名称

IPADDR=172.25.0.100                      ##IP

NETMASK=255.255.255.0 | PREFIX=24        ##子网掩码

 

 wKioL1jvL9HSTwheAAAyxDROwC4501.jpg

 

3.gateway 网关

 

1.路由器

主要功能是用来作nat的

dnat目的地地址转换

snat源地址转换

 

2.网关

路由器上和自己处在同一个网段的那个ip

 

3.设定网关

systemctl stop NetwrokManager

vim /etc/sysconfig/network                              ##全局网关

GATEWAY=网关ip

 

vim /etc/sysconfig/network-scripts/ifcfg-网卡配置文件    ##网卡接口网关

GATEWAY=网关ip

 

systemctl restart netwrok

 

route -n                                                 ##查询网关

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0   (网关)172.25.0.254    0.0.0.0         UG    0      0        0 eth0

172.25.0.0      0.0.0.0         255.255.255.0   U     0      0        0 eth0

 

 wKiom1jvL-rBsr_bAAAaPdhG5h0986.jpg

 

5.dns

1.dns

dns是一台服务器

这太服务器提供了回答客户主机名和ip对应关系的功能

 

2.设定dns

vim /etc/resolv.conf

nameserver dns服务器ip

 

vim /etc/sysconfig/network-scripts/ifcfg-网卡配置文件

DNS1=dns服务器ip

 

3.本地解析文件

vim /etc/hosts

ip主机名称

 

4.本地解析文件和dns读取的优先级调整

/etc/nsswitch.conf

 38 #hosts:     db files nisplus nis dns

 39 hosts:      files dns##files代表本地解析文件,dns代表dns服务器,那个在前面那个优先

 

 

5.dhcp服务的配置


本文转自  夏梨巴人  51CTO博客,原文链接:http://blog.51cto.com/12774035/1915653
相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
基于阿里云,构建一个企业web应用上云经典架构,让IT从业者体验企业级架构的实战训练。
相关文章
|
13天前
|
存储 Linux
Linux的学习之路:16、文件(3)
Linux的学习之路:16、文件(3)
23 0
|
13天前
|
Linux C语言 C++
Linux的学习之路:14、文件(1)
Linux的学习之路:14、文件(1)
22 0
|
13天前
|
Linux 开发工具 C语言
Linux的学习之路:7、yum与git
Linux的学习之路:7、yum与git
11 0
|
13天前
|
Linux 开发工具
Linux的学习之路:5、粘滞位与vim
Linux的学习之路:5、粘滞位与vim
37 0
|
13天前
|
人工智能 Unix Linux
Linux的学习之路:1、发展史与编译环境的搭建
Linux的学习之路:1、发展史与编译环境的搭建
13 0
|
13天前
|
人工智能 Unix Linux
Linux的学习之路:2、基础指令(1)
Linux的学习之路:2、基础指令(1)
26 0
|
13天前
|
Unix Linux Windows
Linux的学习之路:3、基础指令(2)
Linux的学习之路:3、基础指令(2)
32 0
|
5天前
|
Ubuntu 算法 Linux
嵌入式Linux的学习误区
该文指出了学习嵌入式Linux开发的两个常见误区。一是过分专注于学习桌面或服务器版Linux,而非关注嵌入式开发本身,实际上只需熟悉基本操作即可。二是试图在没有基础的情况下直接阅读Linux内核源代码,这是不切实际的,应先建立基础知识再进行源码学习。文章还提到了在嵌入式系统中获取和处理屏幕数据的示例,包括使用gsnap工具将framebuffer数据转为图像,以及涉及的交叉编译过程。
9 0
|
6天前
|
编解码 Linux 数据安全/隐私保护
【Linux学习】​​学习Linux的准备工作和Linux的基本指令
【Linux学习】​​学习Linux的准备工作和Linux的基本指令
|
6天前
|
Linux Shell 虚拟化
【Linux学习】Linux 的虚拟化和容器化技术
【Linux学习】Linux 的虚拟化和容器化技术