当前位置:网站首页>网络参数管理
网络参数管理
2022-07-22 22:24:00 【爱吃香菜的猪】
网络参数管理
一、网络参数
主机名、IP地址、子网掩码、网关、DNS服务器地址
1、配置主机名
[[email protected] ~]# hostname
localhost
[[email protected] ~]# hostnamectl set-hostname node1.linux.com
[[email protected] ~]# hostname
node1.linux.com
建议以FQDN(完全合格域名)的方式为主机命名 x.y.z
centos 7 主机名配置文件: /etc/hostname
centos 6.x设置主机名
hostname xx.xx.xx
配置文件: /etc/sysconfig/network
二、IP地址
1、作用
在网络中唯一标识一个节点的地址
用于主机间相互通信的地址
在网络中,任意两个节点间的相互通信只能依靠IP地址
2、组成
由32位二进制数字组成,每8位一组,中间使用点隔开
xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx
11000000.10101100.00000001.00000001
为了方便人记忆地址,每8位二进制数转换成十进制数字进行表示, 192.168.1.1
0.0.0.0 --- 255.255.255.255
IP地址表示方法:
点分十进制表示
3、类型
根据IP地址第一个字节的大小来分
A类 0------127
B类 128----191
C类 192----223 单播地址 Unicast
D类 224----239 组播地址 Multicast
E类 240----255 科研
windows查看IP地址
ipconfig
单播地址 Unicast
在同一个网络中,一个地址只能用于标识一个设备
组建公司、校园的局域网、互联网
组播地址 Multicast
一个地址可用于标识一组设备
应用场景: 交通行业、电话会议、视频会议
根据IP地址的作用
私网IP
免费、在不同的网络中可重复使用
不能直接访问互联网的, 借助NAT技术【网络地址转换】实现访问互联网
适用于局域网构建
私网网段
10.0.0.0 ----- 10.255.255.255
172.16.0.0 ----- 172.31.255.255
192.168.0.0 ---- 192.168.255.255
公网IP
可直接访问互联网的地址
三、子网掩码 netmask
1、默认子网掩码
A类 255.0.0.0 /8
B类 255.255.0.0 /16
C类 255.255.255.0 /24
IP地址完整表示方法
192.168.1.1/255.255.255.0 192.168.1.1/24 CIDR
10.1.1.1/255.0.0.0 10.1.1.1/8 CIDR
2、判断多个IP地址是否属于同一个网段?
网段: 用于表示多个连续的IP地址
只有相同网段的IP地址可相互通信
计算IP地址属于哪个网段?
将IP地址、子网掩码分别转换为二进制数, 按位进行与运算,计算的结果称为网段
192.168.1.127/24
11000000.10101100.00000001.01111111
11111111.11111111.11111111.00000000
11000000.10101100.00000001.00000000
192 168 1 0/24
3、判断IP地址是否为有效地址?
IP地址组成结构:
网络位 + 主机位
主机位: 子网掩码0对应的IP地址部分称为主机位
依据:
从二进制角度,IP地址的主机位不能全为0, 不能全为1
主机位是全0, 称为网段,用于代表一串连续的IP地址
主机位是全1, 称为广播地址
4、计算网段IP地址范围?
计算网段中的IP个数:
2^主机位次方
有效IP个数:
2^主机位次方 - 2
第一个有效IP:最小的加1
最后一个有效IP:最大的减1
192.168.1.0/24 2^8=256
11000000.10101100.00000001.00000000
最小加1 11000000.10101100.00000001.00000001
11000000.10101100.00000001.11111111
最大减1 11000000.10101100.00000001.11111110
11111111.11111111.11111111.00000000
192.168.1.0 ----- 192.168.1.255
192.168.1.1 ----- 192.168.1.254
四、网关 gateway
作用: 不同网络的出口 ,用于不同网段之间的通信
配置网关,相当于告诉主机,当与不同网段的地址通信,先把数据发送到哪
五、DNS服务器地址
解析主机名、IP地址间的对应关系
六、配置Linux主机网络参数
1、查看IP
[[email protected] ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.183.200 netmask 255.255.255.0 broadcast 192.168.183.255
inet6 fe80::d592:68ee:c832:1379 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:53:51:14 txqueuelen 1000 (Ethernet)
RX packets 143 bytes 12870 (12.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 111 bytes 16050 (15.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
网卡状态 UP/down
网卡流量
RX:接收的数据量
TX:发送的数据量
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 12 bytes 1404 (1.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12 bytes 1404 (1.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[[email protected] ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
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: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:53:51:14 brd ff:ff:ff:ff:ff:ff
inet 192.168.183.200/24 brd 192.168.183.255 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::d592:68ee:c832:1379/64 scope link
valid_lft forever preferred_lft forever
2、查看网关
[[email protected] ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.183.2 0.0.0.0 UG 100 0 0 ens33
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
192.168.183.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
3、查看DNS服务器地址
[[email protected] ~]# cat /etc/resolv.conf
# Generated by NetworkManager
search linux.com
nameserver 114.114.114.114
nameserver 202.106.0.20
4、修改网卡配置
方法1: 编辑网卡的配置文件
/etc/sysconfig/network-scripts/ifcfg-网卡名称
[[email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
BOOTPROTO=none //设置手动配置地址
IPADDR=192.168.1.1
PREFIX=24
GATEWAY=192.168.1.254
DNS1=8.8.8.8
DNS2=4.4.4.4
NAME=ens33
DEVICE=ens33
ONBOOT=yes //开机自动激活网卡
[[email protected] ~]# nmcli connection reload
[[email protected] ~]# nmcli connection up ens33
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
方法2: nmcli命令
1、查看网卡配置、删除网卡配置
[[email protected] ~]# nmcli connection show
NAME UUID TYPE DEVICE
ens33 c96bc909-188e-ec64-3a96-6a90982b08ad 802-3-ethernet ens33
virbr0 965675f3-73e3-467a-808e-240b5c8414c1 bridge virbr0
Wired connection 1 3efddd1e-bcd9-3f94-a2b7-1df363c76a83 802-3-ethernet --
[[email protected] ~]# nmcli connection delete 3efddd1e-bcd9-3f94-a2b7-1df363c76a83
Connection 'Wired connection 1' (3efddd1e-bcd9-3f94-a2b7-1df363c76a83) successfully deleted.
[[email protected] ~]# nmcli connection show
NAME UUID TYPE DEVICE
ens33 c96bc909-188e-ec64-3a96-6a90982b08ad 802-3-ethernet ens33
virbr0 965675f3-73e3-467a-808e-240b5c8414c1 bridge virbr0
2、 编辑网卡配置
[[email protected] ~]# nmcli connection add type ethernet ifname ens37 con-name ens37
[[email protected] ~]# nmcli connection modify ens37 ipv4.addresses "192.168.2.1/24"
[[email protected] ~]# nmcli connection modify ens37 ipv4.gateway "192.168.2.254"
[[email protected] ~]# nmcli connection modify ens37 ipv4.dns "114.114.114.114"
[[email protected] ~]# nmcli connection modify ens37 +ipv4.dns "202.106.0.20"
[[email protected] ~]# nmcli connection modify ens37 ipv4.method manual
[[email protected] ~]# nmcli connection reload
[[email protected] ~]# nmcli connection up ens37
边栏推荐
- The Chinese and English dot matrix character display principle of the 111th blog of the fledgling Xiao Li
- [day 31] given an integer n, find the base and exponent of each prime factor | basic theorem of arithmetic
- matlab声音信号处理 频率图 信号过滤和播放声音
- 互联网流量编排方案
- networkx对图进行可视化
- Go 语言的 RSA 用秘钥解析JSEncrypt.js 这个库加密的密文失败
- General, special and hidden attributes of the file (instance generates animation)
- MPLS VPN 跨域-optionB
- 21 -- product of arrays other than itself
- 读书笔记->统计学】12-02 置信区间的构建-t分布概念简介
猜你喜欢

Mysql A left(right) join B on A.id=B. ID and a.age=1 and a left (right) join b on a.id=b id where A.age=1

大咖訪談 | 開源社區裏各種奇怪的現狀——夜天之書陳梓立tison
![Reading notes - > statistics] construction of 12-02 confidence interval -t distribution concept introduction](/img/4d/25b4d3d6af0fb30c222613d3c428b7.png)
Reading notes - > statistics] construction of 12-02 confidence interval -t distribution concept introduction

Experiment 2 YUV

机器学习笔记 - 基于深度学习(HomographyNet)的图像单应性估计

Learn these SketchUp skills and improve work efficiency by half

实验五 JPEG

Example analysis of SQL error reporting and blind injection

【读书笔记->统计学】12-01 置信区间的构建-置信区间概念简介

PNY file to picture
随机推荐
改变this指向了解一下
如何高效安装MindSpore的GPU版本
轮毂电机主动减振系统及其垂向性能优化
Qt+VTK+PCL图片转灰度图且以灰度为Y轴显示
数据脱敏的场景与价值【总结】
Live broadcast preview | live broadcast Seminar on open source security governance models and tools
RequestContextHolder
HCIP --- BGP综合实验
Networkx visualizes graphs
Google Earth engine app - a complete map legend app (land use classification of western United States)
It can't be true? Nailing has been downloaded. Don't you know you can play like this?
Istio架构扩展机制
目标检测之锚点与锚框
Worthington溶菌酶技术说明及文献参考
pip更新一个package
Google Earth Engine APP——一个完整的地图图例APP(美国西部土地利用分类)
批量可视化目标检测标注框——YOLO格式数据集
There are 13 detailed methods for JMeter to view the response of the result tree!
Detailed analysis of the 110th blog of the fledgling Xiao Li in stm32__ NVIC_ Setprioritygrouping (uint32_t prioritygroup) function
树以及二叉树的常用性质以及遍历