Linux运维学习 Day29
综合架构开场章节
一.系统路由配置:
作用: 路由网络线路可以进行选路
1.系统静态默认路由配置 (临时配置)
(1) centos6 (net-tools)
添加静态默认路由
[root@oldboyedu ~]# route add default gw 10.0.0.254
[root@oldboyedu ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.0.254 0.0.0.0 UG 0 0 0 eth0
10.0.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
[root@oldboyedu ~]# ping 223.5.5.5
PING 223.5.5.5 (223.5.5.5) 56(84) bytes of data.
64 bytes from 223.5.5.5: icmp_seq=1 ttl=128 time=27.2 ms
删除静态默认路由
[root@oldboyedu ~]# route del default gw 10.0.0.254
[root@oldboyedu ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
(2) centos7 (iproute)
添加静态默认路由
[root@oldboyedu ~]# ip route add default via 10.0.0.254
[root@oldboyedu ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.0.254 0.0.0.0 UG 0 0 0 eth0
10.0.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
[root@oldboyedu ~]# ping 223.5.5.5
PING 223.5.5.5 (223.5.5.5) 56(84) bytes of data.
64 bytes from 223.5.5.5: icmp_seq=1 ttl=128 time=27.4 ms
删除静态默认路由
[root@oldboyedu ~]# ip route del default via 10.0.0.254
[root@oldboyedu ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
2.系统静态网段路由配置
(1) centos6 (net-tools)
添加静态网段路由
[root@oldboyedu ~]# route add -net 223.5.5.0 netmask 255.255.255.0 gw 10.0.0.254
[root@oldboyedu ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
223.5.5.0 10.0.0.254 255.255.255.0 UG 0 0 0 eth0
删除静态网段路由
route del -net 223.6.6.0 netmask 255.255.255.0 gw 10.0.0.254
(2) centos7 (iproute)
添加静态默认路由
[root@oldboyedu ~]# ip route add 223.6.6.0/24 via 10.0.0.254
[root@oldboyedu ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
223.6.6.0 10.0.0.254 255.255.255.0 UG 0 0 0 eth0
删除静态默认路由
ip route del 223.6.6.0/24 via 10.0.0.254
3.系统静态主机路由配置
(1) centos6 (net-tools)
添加静态主机路由
[root@oldboyedu ~]# route add -host 223.5.5.5 gw 10.0.0.254
[root@oldboyedu ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
223.5.5.5 10.0.0.254 255.255.255.255 UGH 0 0 0 eth0
[root@oldboyedu ~]# ping 223.5.5.5
PING 223.5.5.5 (223.5.5.5) 56(84) bytes of data.
64 bytes from 223.5.5.5: icmp_seq=1 ttl=128 time=26.9 ms
[root@oldboyedu ~]# ping 223.5.5.6
connect: 网络不可达
删除静态主机路由
route del -host 223.5.5.5 gw 10.0.0.254
(2) centos7 (iproute)
添加静态主机路由
[root@oldboyedu ~]# ip route add 223.5.5.5/32 via 10.0.0.254
[root@oldboyedu ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
223.5.5.5 10.0.0.254 255.255.255.255 UGH 0 0 0 eth0
[root@oldboyedu ~]# ping 223.5.5.5
PING 223.5.5.5 (223.5.5.5) 56(84) bytes of data.
64 bytes from 223.5.5.5: icmp_seq=1 ttl=128 time=32.3 ms
[root@oldboyedu ~]# ping 223.5.5.6
connect: 网络不可达
删除静态主机路由
ip route del 223.5.5.5/32 via 10.0.0.254
二.企业网络配置说明:
第一个里程: 进行网络拓扑规划
第二个里程: 路由器上配置
① 配置路由接口地址
② 配置外网拨号设置
③ 配置动态获取地址(DHCP)
第三个里程: 交换机配置
配置交换机vlan设置: (命令行)
PS: 交换机所有的接口属于一个广播域
1.创建vlan
vlan xxx
2.将指定接口划入指定vlan中
switchport access vlan 10
trunk: 对传输数据不打标, 允许不同vlan数据包进行传输
设置方式:指定接口模式 sw mode trunk
虚拟主机上网原理
问题一: ssh远程连接不上
虚拟主机网络信息:
1. 虚拟网卡地址配置
2. 确认选择虚拟网卡
3. 确认远程服务开启
4. 确认安全服务关闭
物理主机网络信息:
1. 确认虚拟网卡激活
2. 确认虚拟网卡地址
3. 确认虚拟网络服务 services.msc
问题二: 无法访问外网
原因:
1. 网卡信息配置
2. 初始化虚拟网络配置
3. 确认虚拟网络服务 services.msc
4. 翻墙代理工具开启
方式: NAT 桥接
三.综合架构部署阶段
1.将基础部分知识进行实际应用
2.综合架构所学习内容企业应用 网站公司 web 机房 监控服务 存储设备
3.综合架构学习各种服务程序 如何学习服务应用 排错配置方法
4.综合架构后续做铺垫 shell mysql数据库 代码上线 jinkens
5.综合架构完后后会有架构述职
四.综合架构组成部分:
01.防火墙服务器 阻止非法入侵 iptables/firewalld
02.负载均衡服务器 调度分配请求信息 nginx/lvs/haproxy
03.网站web服务器 处理用户访问请求 nginx/apache/tomcat/php/python
04.数据库服务器 存储字符信息 mysql/mariadb/oracle(数据库)
05.存储服务器 存储图片/视频/音频 nfs/分布式存储
06.缓存服务器 内存存储数据 memcache/redis/mongodb
07.vpn服务器 用户身份认证 pptp vpn (自己研究)
08.跳板机服务器 监管作用 jumpserver(自己研究)
09.批量管理服务器 批量管理 ansible/saltstack
10.监控服务器 监控服务运行状态 zabbix
11.备份服务器 备份数据 rsync
五.综合架构环境准备:
1.网络配置进行调整
① 需要添加网卡信息
② 配置网卡地址信息
2.进行系统基础优化
① 关闭系统安全策略
getenforce
systemctl stop firewalld.service
systemctl disable firewalld.service
② 更新yum源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
③ 更新系统字符集
④ 更新本地hosts文件
3.虚拟主机克隆操作
① 虚拟主机目录规划
② 虚拟主机克隆操作
PS: 虚拟主机克隆好,一台一台开启进行修改网络配置
4.虚拟主机克隆后调整
修改主机名称:
hostnamectl set-hostname backup
修改主机网卡地址:
sed -ri 's#200#41#g;/UUID|HWADDR/d' /etc/sysconfig/network-scripts/ifcfg-eth[01]