Linux Unit10
来源:互联网 发布:js input name 数组 编辑:程序博客网 时间:2024/05/16 07:06
管理网络
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 addr show eth0
ping -c 1 -w 1
ip route
traceroute
ifconfig 网卡 ip netmask –> 临时设定
ifconfig可查看IP
nmcli connection add type ethernet con-name westos ifname eth0 autoconnect yes –> 添加dhcp网络
nmcli connection add type ethernet con-name westos ifname eth0 ip4 ip/24 –> 添加静态网络
nmcli connection delete westos –> 删除westos链接
nmcli connection show –> 显示所有网络链接
nmcli connection down westos –> 关闭指定链接
nmcli connection up westos –> 开启指定链接
nmcli connection modify “westos” ipv4.addresses newip/24 –> 改变wetos的ip
nmcli connection modify “westos” ipv4.method < auto|manual> –> 改变westos的工作方式为动态或者静态
nmcli device connect eth0 –> 开启设备
nmcli device disconnect eth0 –> 关闭设备
nmcli device show –> 显示设备信息
nmcli device status –> 显示设备状态
<<文件>>
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 –> 子网掩码
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
【4】网关配置文件
/etc/sysconfig/gateway
GATEWAY=IP
route -n
网卡的配置文件中也可以设定网关
4.DNS
【1】DNS定义:
DNS(Domain Name System,域名系统),因特网上作为域名和IP地址相互映射的一个分布式数据库,能够使用户更方便的访问互联网,而不用去记住能够被机器直接读取的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服务的配置
网络管理文件:
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 –> 接口使用设备
BOOTPROTO=dhcp –> 网卡工作模式
ONBOOT=yes –> 网络服务开启时自动激活
NAME=eth0 –> 网络接口名称
IPADDR=172.25.0.100
NETNASK=255.255.255.0
子网掩码,也可通过PREFIX=24
- Linux Unit10
- linux初学 unit10
- linux初学 unit10 练习
- unit10
- unit10
- unit10
- unit10
- Linux学习篇之~unit10
- Linux基础学习——unit10
- Linux学习篇之~unit10练习
- linux学习总结 unit10打包与压缩
- Linux学习篇第二章之~unit10 selinux
- Unit10 文档
- unit10 practice
- unit10 练习题
- english book1 unit10
- Unit10 作业练习
- unit10 日志同步
- lower_bound
- 能解开assetbundle格式资源的UnityStudio工具
- 最全的Android安全工具合集
- 安装linux开发板以及裸机程序烧写
- 安装MariaDB
- Linux Unit10
- 第一个只出现一次的字符 (剑指offer)
- 二叉树的深度遍历和广度遍历
- MATLAB数值分析笔记大纲
- LeetCode-66:Plus One (数组看作数据 加1)
- cocos2dx手游开发之环境搭建
- 01:初识Spring
- CS Maxor 或运算,DP(SOS)
- SpringBoot从入门到精通