route命令实例练习
第1章 命令配置
|
虚拟服务器 |
网卡配置信息 |
虚拟网卡名称 |
虚拟网卡模式 |
|
服务器01 |
eth1 |
10.0.0.10/24 |
nat模式 |
|
服务器02 |
eth2 |
10.0.0.11/24 |
nat模式 |
|
eth3 |
10.0.1.11/24 |
主机模式 |
|
|
服务器03 |
eth2 |
10.0.1.10/24 |
主机模式 |
1.1 查看三台主机的路由表
1.1.1 服务器01
[root@route-01 ~]# 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 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth1
0.0.0.0 10.0.0.254 0.0.0.0 UG 0 0 0 eth1
1.1.2 服务器02
[root@route-02 ~]# 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 0 0 0 eth2
10.0.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth3
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth2
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth3
0.0.0.0 10.0.1.254 0.0.0.0 UG 0 0 0 eth3
1.1.3 服务器03
[root@route-03 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth2
0.0.0.0 10.0.1.254 0.0.0.0 UG 0 0 0 eth2
1.2 服务器主机配置
1.2.1 服务器01配置路由信息
[root@route-01 ~]# route add -net 10.0.1.0/24 gw 10.0.0.11
[root@route-01 ~]# 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 0 0 0 eth1
10.0.1.0 10.0.0.11 255.255.255.0 UG 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth1
0.0.0.0 10.0.0.254 0.0.0.0 UG 0 0 0 eth1
说明:利用添加网络路由条目命令,在服务器上正确添加上一条去往10.0.1.0 网段的路由条目
1.2.2 服务器03上配置网络路由条目
[root@route-03 ~]# route add -net 10.0.0.0/24 gw 10.0.1.11
[root@route-03 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.0.0 10.0.1.11 255.255.255.0 UG 0 0 0 eth2
10.0.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth2
0.0.0.0 10.0.1.254 0.0.0.0 UG 0 0 0 eth2
说明:利用添加网络路由条目命令,在服务器上正确添加上一条去往10.0.0.0网段条目
1.2.3 在服务器02 上开启路由转发
服务器02主机在拓扑中负责进行路由转发,需要开启相关参数。
[root@route-02 ~]# vim /etc/sysctl.conf
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
#
# Use '/sbin/sysctl -a' to list all possible parameters.
# Controls IP packet forwarding
net.ipv4.ip_forward = 1
1.2.3.1 显示转发信息
[root@route-02 ~]# sysctl -p
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
1.3 虚拟主机路由访问验证
1.3.1 在服务器01 上验证
[root@route-01 ~]# traceroute 10.0.1.10
traceroute to 10.0.1.10 (10.0.1.10), 30 hops max, 60 byte packets
1 10.0.0.11 (10.0.0.11) 0.252 ms 0.231 ms 0.199 ms
2 10.0.1.10 (10.0.1.10) 0.999 ms !X 0.970 ms !X 0.940 ms !X
说明:通过 traceroute 路由路径追踪命令,已确认路由走向符合配置需求,即路由配置正确无误。
!X 表示已经完成路由追踪过程。
1.3.2 服务器03上进行验证
[root@route-03 ~]# traceroute 10.0.0.10
traceroute to 10.0.0.10 (10.0.0.10), 30 hops max, 60 byte packets
1 10.0.1.11 (10.0.1.11) 0.287 ms 0.209 ms 0.176 ms
2 10.0.0.10 (10.0.0.10) 0.469 ms !X 0.526 ms !X 0.498 ms !X
说明:通过 traceroute 路由路径追踪命令,已确认路由走向符合配置需求,即路由配置正确无误。
!X 表示已经完成路由追踪过程。
第2章 linux 路由部署项目结论
整体配置部署步骤已符合原有项目需求,生产环境中,已经可以满足 3 台服务器主机在正常访问外网的同时,可以利用服务器路由转发功能与服务器网路路由配置,实现内网环境跨网段进行通讯需求。
2.1 linux 路由部署异常分析
2.1.1 防火墙异常问题
服务器主机 02 起到路由转发功能,类似于路由器的角色,因此服务器上防火墙功能需要关闭,否则防火墙相应条目会阻止掉路由转发流量。
2.1.2 虚拟网卡异常问题
服务器主机网卡信息配置中,尽量选择 nat 模式或者仅主机模式网卡进行配置,不要选择LAN 区段网卡配置方式,否则根据虚拟软件网络工作原理,LAN 区段网卡配置模式无法进行路由的转发,会影响最终配置效果。
route命令实例练习的更多相关文章
- route命令详解与使用实例
1. 使用背景 需要接入两个网络,一个是部署环境所在内网环境,这个环境是上不了外网, 外网环境很可能是一个无线网络.如果两者都连接上,很可能导致有一方不能起作用,即外网或内网上不了,常常需要使用繁 ...
- route命令详解与使用实例 ,同时访问内外网
route命令详解与使用实例 2011-10-18 12:19:41| 分类: 其他 | 标签:route |字号 订阅 1. 使用背景 需要接入两个网络,一个是部署环境所在内 ...
- 每天一个linux命令(53):route命令
Linux系统的route命令用于显示和操作IP路由表(show / manipulate the IP routing table).要实现两个不同的子网之间的通信,需要一台连接两个网络的路由器,或 ...
- 路由知识之ip route 命令中的疑惑
1.基础知识 1.1 路由 (Routing) 1.1.1 路由策略 (使用 ip rule 命令操作路由策略数据库) 基于策略的路由比传统路由在功能上更强大,使用更灵活,它使网络管理员不仅能够根据目 ...
- 每天一个linux命令:route命令
Linux系统的route命令用于显示和操作IP路由表(show / manipulate the IP routing table).要实现两个不同的子网之间的通信,需要一台连接两个网络的路由器,或 ...
- route命令
Linux系统的route 命令用于显示和操作IP路由表(show / manipulate the IP routing table).要实现两个不同的子网之间的通信,需要一台连接两个网络的路由器, ...
- 每天一个linux命令(45):route命令
Linux系统的route 命令用于显示和操作IP路由表(show / manipulate the IP routing table).要实现两个不同的子网之间的通信,需 要一台连接两个网络的路由器 ...
- route命令(转)
Linux系统的route命令用于显示和操作IP路由表(show / manipulate the IP routing table).要实现两个不同的子网之间的通信,需要一台连接两个网络的路由器,或 ...
- Linux route命令详解和使用示例(查看和操作IP路由表)
Linux系统的route命令用于显示和操作IP路由表(show / manipulate the IP routing table).要实现两个不同的子网之间的通信,需要一台连接两个网络的路由器,或 ...
随机推荐
- ios开发——实用技术篇&三维旋转动画
实现三位旋转动画的方法有很多种,这里介绍三种 一:UIView 1 [UIView animateWithDuration:1.0 animations:^{ 2 self.iconView.laye ...
- Linux学习——shell编程之运算符
shell编程之运算符 一:shell中常见算术运算符号和优先级 二:算术运算符 Shell 变量:是弱类型!不能进行加减乘除!比较麻烦! 例子 :shell变量弱类型 a=11 b=22 echo ...
- electron入门心得
前言 前端开发桌面程序这个概念已经出现有一段时间了,这项技术也已经走向成熟,Github上nw和光electron的star就差不多有10w颗星了,github也衍生出了很多开源的桌面项目俨然成了一个 ...
- hdu4632
Palindrome subsequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65535 K (Java/ ...
- PHP字符串函数-trim()实例用法
string trim ( string $str [, string $charlist = " \t\n\r\0\x0B" ] )此函数返回字符串 str 去除首尾空白字符后的 ...
- 自适应 Tab 宽度可以滑动文字逐渐变色的 TabLayout(仿今日头条顶部导航)
TabLayout相信大家都用过,2015年Google大会上发布了新的Android Support Design库里面包含了很多新的控件,其中就包含TabLayout,它可以配合ViewPager ...
- Python自学笔记-filter()函数(来自廖雪峰的官网Python3)
感觉廖雪峰的官网http://www.liaoxuefeng.com/里面的教程不错,所以学习一下,把需要复习的摘抄一下. 以下内容主要为了自己复习用,详细内容请登录廖雪峰的官网查看. Python内 ...
- zoj 2136 Longest Ordered Subsequence 最长上升子序列 新思路
Longest Ordered Subsequence Time Limit: 2 Seconds Memory Limit: 65536 KB A numeric sequence of ...
- Bootstrap文本排版基础--Bootsrap
1.排版前的基础 (1)移动设备优先 <meta name="viewport" content="width=device-width, initial-scal ...
- ios获取本机网络IP地址方法
#include <ifaddrs.h> #include <arpa/inet.h> - (NSString *)getIPAddress { N ...