Sie sind auf Seite 1von 33

Linux 操作 系统

网络管理

周炯
上海艾基信 息技术有限 公司

Acegene IT Co. Ltd. 1


内容简 介
•1 C/S 模型
•2 路由管理
•3 ppp 配置
•4 VPN

Acegene IT Co. Ltd. 2


1 C/S 模型
• C/S 介绍
• 守护进程 xinetd
• RPC

Acegene IT Co. Ltd. 3


1 xinetd 守护进 程
• xinetd(eXtended InterNET services daemon) 提供类似于 inetd+tcp_wrapper 的功能,但
是更加强大和安全。它能提供以下特色: 
*  支持对 tcp 、 ucp 、 RPC 服务 ( 但是当前对 RPC 的支持不够稳定 ) 
*  基于时间段的访问控制 
*  功能完 的 log 功能,即可以记录连接成功也可以记录连接失败的行为 
*  能有效的防止 DoS 攻击 (Denial of Services) 
*  能限制同时运行的同意类型的服务器数目 
*  能限制启动的所有服务器数目 
*  能限制 log 文件大小 
*  将某个服务绑定在特定的系统接口上,从而能实现只允许私有网络访问某项服务 
*  能实现作为其他系统的代理。如果和 ip 伪装结合可以实现对内部私有网络的访问 
 它最大的缺点是对 RPC 支持的不稳定性,但是可以启动 protmap ,与 xinetd 共存来解决这个
问题 

Acegene IT Co. Ltd. 4


1 编译安 装
• www.xinetd.org 下载 xinetd
• configure 选项 :
– --with-libwrap : 根据 tcpd 配置文件
(/etc/hosts.{allow ,  deny}) 来进行访问控制
– --with-loadavg: 在系统负载过重时关闭某些服务
进程,来实现某些 DoS 攻击。
– --with-inet6 :  使用该选项 xinetd 将支持 IPv6

Acegene IT Co. Ltd. 5


1 配置文 件
配置方式:
/etc/xinetd.conf 和 /etc/xinetd.d
基本格式:
Service service_name
{
..
}
其中是属性表,每个属性可指定一个值,使用 = ,
部分属性支持 += , -= 实现在原有的基础上加
、减某值。

Acegene IT Co. Ltd. 6


1 servers
• 实现提供当前运行在服务器上的进程表 , 以及有
关这些进程的确切信息 , 如:
• Service servers 

      type = INTERNAL UNLISTED 
      Socket_type = stream 
      Protocol = tcp 
      Port = 9997 
      Wait = no 
      Only_from = 172.17.33.111 
      Wait = no 

Acegene IT Co. Ltd. 7


1 Services
• services 特定项的目的是提供可用服务的列表
• Service services 

     type = INTERNAL UNLISTED 
     Socket_type = stream 
     protocol = tcp 
     port = 8099 
     wait = no 
     Only_ from = topcat 

Acegene IT Co. Ltd. 8


1 Xadmin
• 这个特定服务项提供以交互方式获得 services 特
定服务所提供信息的方法
• Service xadmin 

     type = INTERNAL UNLISTED 
     socket_type = stream 
     protocol = tcp 
     port = 9967 
     wait = no 
     Only_from = topcat 

Acegene IT Co. Ltd. 9


2 Linux 路由实现

• 路由器简介
• 用 Linux 主机作静态路由
• 用 GateD 实现动态路由

Acegene IT Co. Ltd. 10


2 路由器简介
• 路由器的基本概念
• 路由器的原理与作用
• 路由器的功能
• Linux 的路由种类

Acegene IT Co. Ltd. 11


路由器的基本概念
• 路由和路由器
• 路由器和交换机的区别
• 路由器的分类 : 硬路由器和软路由器

Acegene IT Co. Ltd. 12


路由器的原理与作用
• 路由选路的方式有两种:静态
( Static )路由和动态( Dynamic )路
由 。

Acegene IT Co. Ltd. 13


静态路 由
• 静态路由是指从每一个源地址到目的地
址的传输都具有固定的路径。一般是根据
网络的配置情况,预先添加到路由表里的。
如果网络设置发生了变化不会自动更新,
需要手动进行更改。

Acegene IT Co. Ltd. 14


动态路 由

• 常用的动态路由协议 :
– RIP 协议
– OSPF 协议
– BGP 协议

Acegene IT Co. Ltd. 15


路由器的功能
• 数据转发
• 路由选择
• 协议转换
• 多种协议的路由选择
• 流量控制
• 分段和组装功能
• 网络管理功能

Acegene IT Co. Ltd. 16


Linux 的路由种类
• 1. 在局域网和外部网之间进行数据包转发

• 2. 分割子网并实现各个逻辑子网间数据包
的转发。
• 3. 用普通 PC 机来作通常意义上的路由器
,也就是架设软路由器。

Acegene IT Co. Ltd. 17


硬件准 备—— 实例( 网络拓扑图 )

Acegene IT Co. Ltd. 18


设置服 务器 IP 地址
• eth0 设置外部网络的 IP 地址 ,其余四个网
络接口分别设置如下内部 IP 地址:
– # ifconfig eth0 202.38.85.10 netmask 255.255.255.0
broadcast 202.38.85.255
– # ifconfig eth1 192.168.1.1 netmask 255.255.255.192
broadcast 192.168.1.64
– # ifconfig eth2 192.168.1.65 netmask 255.255.255.192
broadcast 192.168.1.128
– # ifconfig eth3 192.168.1.129 netmask
255.255.255.192broadcast 192.168.1.192
– # ifconfig eth4 192.168.1.193 netmask
255.255.255.192broadcast 192.168.1.255
• 或编辑 /etc/sysconfig/network-scripts/ 目录下的启动
脚本文件 。

Acegene IT Co. Ltd. 19


设置路 由
• # route add -net 202.38.85.0 netmask 255.255.255.0 dev
eth0
• #route add -net 192.168.1.0 netmask 255.255.255.192
dev eth1
• #route add -net 192.168.1.64 netmask 255.255.255.192
dev eth2
• #route add -net 192.168.1.128 netmask 255.255.255.192
dev eth3
• # route add -net 192.168.1.192 netmask 255.255.255.192
dev eth4

• 最后指定默认网关 :
• # route add default gw 202.38.85.1

Acegene IT Co. Ltd. 20


配置客户端和检测路由设置
• 1. 在一个子网内的一台客户机上,检测能
否连通本子网的网关。
• 2. 在一个子网内的一台客户机上,检测能
否连通另一个子网的网关。
• 3. 在一个子网的一台客户机上,检测是否
能够连通另一个子网内的一台客户机。
• 4. 最后在一个子网的一台客户上,检测是
否能够连通外部网络。

Acegene IT Co. Ltd. 21


用 GateD 实现动态路由
• GateD 简介
• 配置 GateD 实现 RIP

Acegene IT Co. Ltd. 22


GateD 简介
• GateD 是一个基于路由协议之间交换信
息产生的路由数据库,来处理动态路由的
软件。它采用了模块化的设计,包括核心
服务程序、路由信息数据库、以及多种协
议的支持模块。 GateD 支持的路由协议主
要有: RIP 、 DCN
HELLO 、 OSPF 、 EGP 和
BGP 。 GateD 最初是被用来连接
NSFNET (美国国家科学基金会 NSF 资助
的关于主干网)网络之间的交界区域。

Acegene IT Co. Ltd. 23


rip 简介
• rip 报文类型:
– 请求报文:查询相邻 RIP 设备,获得它们的距
离向量表
– 响应报文:公告它的本地距离向量表中的信息
– 在以下情况下发出:
• 每隔 30 秒发送一次
• 对另一个 RIP 结点产生的请求报文的响应
• 如果支持触发式,则在本地距离向量表发生变化时
被发出。
• RIP 使用 520 端口发送和接收,每个数据
报最大为 512 字节

Acegene IT Co. Ltd. 24


rip 分类
• rip-1:
• rip-2:
– 支持 CIDR 和 VLSM
– 支持组播
– 支持认证
– 支持 rip-1
• rippng:
– 支持 IPV6 的认证
– 支持 IPV6 地址
– 使用 521 端口
• RIP 协议缺点:
– 路径代价限制和收敛时间长

Acegene IT Co. Ltd. 25


Rip 配置
• rip yes |no|off [ {
– broadcast;
– nobroadcast;
– nocheckzero;
– preference preference;
– defaultmetric metric;
– query authentication [none|[[simple|md5]paswd]];
– interface interface_list
• [noripin]|[ripin]
• [noripout]|[ripout]
• [metricin metric]
• [version1]|[version2[multicast|broadcast]]
• [[secondary]authentication[none|[[simple|
md5]password]];
• trustedgateways gateway_list;
• sourcegateways gateway_list;
• traceoptions trace_options;
• }];
Acegene IT Co. Ltd. 26
Gated.conf 配置
• Broadcast: 指定 rip 包被广播发送
• Nobroadcast: 在绑定的接口上不广播 rip 包
• Nocheckzero: 指定 rip 不处理 RIP 包中的保留域
• Preference [n]: 设置 rip 路由的 preference, 默认为
100
• Metric [n]: 尺度 ( 默认为 16)
• Query authentication: 设置身份认证方式
• Interface interface_list: 针对接口进行参数设定
• Trustedgateways gateway_list: 定义接收更新包的网

• Sourcegateways gateway_list: 直接发送 rip 的路由
器列表
• Traceoptions trace_options: 设置 RIP 跟踪选项

Acegene IT Co. Ltd. 27


INTERFACE_LIST 选项
• noripin: 忽略指定接口接收到的 RIP 包
• ripin: 默认的设置参数
• noripout: 指定接口上不向外发送 rip 包
• ripout: 默认的设置参数
• metricin metric: 加入核心路由表前,增加的尺度
• metricout metric: 在指定的接口发出 rip 包前,增加的
尺度
• version 1: 发送第一个版本的 rip 协议的数据包
• version 2: 指定发送第二个版本的 rip 协议的数据包。
• multicast: 在指定接口上的发送第二版本的 RIP 包用组
播方式
• broadcast: 指定在特定的接口上,使用广播方式来发送

Acegene IT Co. Ltd. 28


配置 GateD 实现 RIP
• rip yes {
• broadcast ;
• defaultmetric 5 ;
• interface eth1 version 2 multicast ;
• };

• static {
• default gateway 202.38.85.1
preference 140 retain ;
• };

Acegene IT Co. Ltd. 29


3 ppp
• http://www.samba.org/ppp/
• http://www.roaringpenguin.com/penguin/open_source_rp-pppoe.php
• 一、编译内核
要建立 PPPOE 服务器,除了内核要支持 PPP 以外还需要内核支持 PPPOE ,不过在
2.4.18 里需要打开内核的不成熟代码才可以选择,内核的配置如下:
code maturity level options——>[*] prompt for development and/or
incomplete code/drivers
networking options——>[*] packet socket[*] packet socket:mmapped io
network device support——>[*] ppp (point-to-point protocol) support[*]
ppp multilink support (experimental)[*] ppp filtering[*] ppp support for
async serial ports[*] ppp support for sync tty ports[*] ppp deflate
compression[*] ppp bsd-compress compression[*] ppp over Ethernet
(experimental)
character devices——>[*] non-standard serial port support[*] hdlc line
discipline support
编辑 /etc/modules.conf ,加入以下几行:
• alias char-major-108 ppp_generic
• alias /dev/ppp ppp_generic
• alias tty-ldisc-3 ppp_async
• alias tty-ldisc-13 n_hdlc
• alias tty-ldisc-14 ppp_synctty
• alias ppp-compress-21 bsd_comp
• alias ppp-compress-24 ppp_deflate
• alias ppp-compress-26 ppp_deflate

Acegene IT Co. Ltd. 30


3 ppp
• 使用 configure
• 使用 make 编译 PPPD ,这里有几个参数比较重要,要支持 windows 的客户端,应该在编译时
加上选项 USE_MS_DNS=1, 如果你的系统 shadow 的话,你应该使用 make HAS—
SHADOW=1 表示支持 shadow 密码
•编译完成后,将生成 pppd 、 pppdump 、 chat 和 pppstats 这几个文件,使用 make install
安装这些文件
启动 PPPOE 进程:
pppoe-server –L 10.0.0.1 –R 10.0.0.2 –N 64 -u
-L: 指定 PPPOE 服务器的 IP 地址
-R : 指定 PPPOE 拨入服务器分配给客户端的 IP 地址段
-N : 允许客户端同时拨入的数量(默认是 64 最大是 65534 )
修改 /etc/ppp/options ,查看有没有以下几行,没有就加进去 :
local
repaire-pap
login
auth
defaultroute
hide-password
ipcp-accept-local
ipcp-accept-remote
10.0.0.1:10.0.0.255
netmask 255.255.255.0
ms-dns 10.0.0.1
修改 /etc/ppp/pppoe-server-options ,将所有的行都注释掉
添加用户到 /etc/ppp/pap-secrets 中 , 例如添加用户 test ,密码为 123456 ,允许从任何位置
拨入 :
#client server secret ip addresses
test * “123456” *

Acegene IT Co. Ltd. 31


4 vpn
• freeswan
• www.freeswan.org

Acegene IT Co. Ltd. 32


Q&
A
QUESTIONS
ANSWERS

Das könnte Ihnen auch gefallen