Chinaunix首页 | 论坛 | 博客
  • 博客访问: 49507
  • 博文数量: 8
  • 博客积分: 176
  • 博客等级: 入伍新兵
  • 技术积分: 85
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-27 08:58
文章分类

全部博文(8)

文章存档

2016年(1)

2015年(1)

2011年(3)

2009年(3)

我的朋友

分类: LINUX

2009-10-06 13:39:42

虚拟了4个ubuntu系统,
两个做路由器(R1,R2),两个做客户机(C1,C2)

两个客户机分别位于两个网段:
A)1.0.0.0    255.0.0.0
B)3.0.0.0    255.0.0.0
客户机配置如下:
C1: 1.0.0.2  255.0.0.0
C2: 3.0.0.2  255.0.0.0
服务器各有两个网卡,设置如下:
R1: 1.0.0.1 255.0.0.0
     2.0.0.1 255.0.0.0
R2: 3.0.0.1 255.0.0.0
     2.0.0.2 255.0.0.0

第一步:
设置如下:
R1:
ifconfig eht0 1.0.0.1 255.0.0.0
ifconfig eth1 2.0.0.1 255.0.0.0
route add -net 3.0.0.0 netmask 255.0.0.0 gw 2.0.0.2
或者设置/etc/network/interface文件:网卡ip
auto eth0
iface eth0 inet static
address 1.0.0.1
netmask 255.0.0.0
auto eth1
iface eth1 inet static
address 2.0.0.1
netmask 255.0.0.0
up route add -net 3.0.0.0 netmask 255.0.0.0 gw 2.0.0.2 eth1

R2:
ifconfig eht0 3.0.0.1 255.0.0.0
ifconfig eth1 2.0.0.2 255.0.0.0
route add -net 1.0.0.0 netmask 255.0.0.0 gw 2.0.0.1
或者设置/etc/network/interface文件:
auto eth0
iface eth0 inet static
address 3.0.0.1
netmask 255.0.0.0
auto eth1
iface eth1 inet static
address 2.0.0.2
netmask 255.0.0.0
up route add -net 1.0.0.0 netmask 255.0.0.0 gw 2.0.0.1 eth1
(另,route del -net 1.0.0.0 netmask 255.0.0.0 可删除该项)

C1:
ifconfig eht0 1.0.0.2 255.0.0.0
或者设置/etc/network/interface文件:
auto eth0
iface eth0 inet static
address 1.0.0.1
netmask 255.0.0.0
up route add -net 3.0.0.0 netmask 255.0.0.0 eth0(因为客户端只有一个网卡,因此不必设置gw、即网关)
C2:
ifconfig eht0 3.0.0.2 255.0.0.0
或者设置/etc/network/interface文件:
auto eth0
iface eth0 inet static
address 3.0.0.1
netmask 255.0.0.0
up route add -net 3.0.0.0 netmask 255.0.0.0 eth0(因为客户端只有一个网卡,因此不必设置gw、即网关)
第二步:
开启两个路由器的路由转发功能:
sysctl net.ipv4.ip_forward=1
或者修改文件/etc/sysctl.conf文件: net.ipv4.ip_forward=1

阅读(1465) | 评论(0) | 转发(0) |
0

上一篇:linux系统管理笔记

下一篇:杂项

给主人留下些什么吧!~~