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**
- 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)系统静态网段路由配置
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`
- 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) 系统静态主机路由配置
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
- 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`
永久生效
1, 查看路由配置
ip route
2, 编辑文件
vim /etc/sysconfig/network-scripts/route-网卡名
2. 企业网络配置说明:
- 第一个里程: 进行网络拓扑规划
- 第二个里程: 路由器上配置
配置路由接口地址
配置外网拨号设置
配置动态获取地址(DHCP)- 第三个里程: 交换机配置
配置交换机vlan设置: (命令行)
PS; 交换机所有的接口属于一个广播域
1.创建vlan
vlan xxx
2.将指定接口划入指定vlan中
switchport access vlan 10
trunk: 对传输数据不打标, 允许不同vlan数据包进行传输
设置方式:
1.指定接口模式
sw mode trunk
虚拟主机上网原理
- 问题一: ssh远程连接不上:
- 虚拟主机网络信息:
虚拟网卡地址配置
确认选择虚拟网卡
确认远程服务开启
确认安全服务关闭
- 物理主机网络信息:
确认虚拟网卡激活
确认虚拟网卡地址
确认虚拟网络服务 services.msc
- 问题二: 无法访问外网
- 原因:
网卡信息配置
初始化虚拟网络配置
确认虚拟网络服务 services.msc
3.综合架构部署阶段
- 将基础部分知识进行实际应用
- 综合架构所学习内容企业应用 网站公司 web 机房 监控服务 存储设备
- 综合架构学习各种服务程序 如何学习服务应用 排错配置方法
- 综合架构后续做铺垫 shell mysql数据库 代码上线 jinkens
- 综合架构完后后会有架构述职 降级制度
4.综合架构组成部分:
1.
防火墙服务器
阻止非法入侵 ----- iptables/firewalld
2.负载均衡服务器
调度分配请求信息 ----- nginx/lvs/haproxy
3.网站web服务器
处理用户访问请求
4.数据库服务器
存储字符信息 ------ mysql/mariadb/oracle(数据库)
5.存储服务器
存储图片/视频/音频 ------nfs/分布式存储
6.缓存服务器
内存存储数据 ------ memcache/redis/mongodb
7.vpn服务器
用户身份认证 -----pptp vpn
8.跳板机服务器
监管作用 ----- jumpserver
9.批量管理服务器
批量管理 ---- ansible/saltstack
10.监控服务器
监控服务运行状态------ zabbix
11.备份服务器
备份数据 ----- rsync
5.综合架构环境准备:
- 1) 网络配置进行调整
a 需要添加网卡信息
b 配置网卡地址信息
``cd /etc/sysconfig/network-scripts/
cp ifcfg-eth0 ifcfg-eth1
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth1
DEVICE=eth1
ONBOOT=yes
IPADDR=172.16.1.200
PREFIX=24
IPV6_PRIVACY=no
systemctl restart network
- 检查确认:
```````[root@oldboyedu network-scripts]# ip a
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:e5:d0:c7 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.200/24 brd 10.0.0.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::560b:9e4b:8f6b:f8fb/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:e5:d0:d1 brd ff:ff:ff:ff:ff:ff
inet 172.16.1.200/24 brd 172.16.1.255 scope global noprefixroute eth1
valid_lft forever preferred_lft forever
inet6 fe80::3a47:1ca6:b9e2:2f6c/64 scope link noprefixroute
valid_lft forever preferred_lft forever```````
- 进行系统基础优化
a 关闭系统安全策略
getenforce
systemctl stop firewalld.service
systemctl disable firewalld.service
b 更新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
c 更新系统字符集
d 更新本地hosts文件
cat >> /etc/hosts <<EOF
10.0.0.5 lb01
10.0.0.6 lb02
10.0.0.7 web01
10.0.0.8 web02
10.0.0.9 web03
10.0.0.31 nfs01
10.0.0.41 backup
10.0.0.51 db01
10.0.0.61 m01
10.0.0.71 zabbix
EOF
- 虚拟主机克隆操作
a 虚拟主机目录规划
b 虚拟主机克隆操作
PS: 虚拟主机克隆好,一台一台开启进行修改网络配置- 虚拟主机克隆后调整
修改主机名称:
hostnamectl set-hostname backup
- 修改主机网卡地址:
sed -ri 's#200#41#g;/UUID|HWADDR/d' /etc/sysconfig/network-scripts/ifcfg-eth[01]