Chinaunix首页 | 论坛 | 博客

  • 博客访问: 898087
  • 博文数量: 226
  • 博客积分: 10077
  • 博客等级: 上将
  • 技术积分: 2708
  • 用 户 组: 普通用户
  • 注册时间: 2008-05-25 14:36
文章分类

全部博文(226)

文章存档

2010年(15)

2009年(82)

2008年(129)

我的朋友

分类: LINUX

2008-07-07 10:19:11

用debian的iptables做简单路由(双网卡)

作者: jsbxw  发布日期: 2008-3-22    查看数: 294   出自:
1.在/etc/rc.d/rc.local中加入如下

(1).如果是DHCP直接上网
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.1.0/24 -j MASQUERADE

(2).如果是ADSL拨号上网
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o ppp0 -s 192.168.1.0/24 -j MASQUERADE

(3).如果是固定IP

iptables -t nat -A POSTROUTING -o eth0 -s 192.168.1.0/24 -j SNAT –to-source 10.4.40.13(固定IP)

2./etc/network/interfaces文件配置
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto dsl-provider
iface dsl-provider inet ppp
pre-up /sbin/ifconfig eth1 up # line maintained by pppoeconf
provider dsl-provider

auto eth1
iface eth1 inet manual

auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0

3.配置客户机网卡
iface eth0 inet static
address 192.168.1.3
netmask 255.255.255.0
gateway 192.168.1.1

如果在上面的服务器下再接一个服务器,配置于上面基本相同,例如:

1.同上(略)

2.配置外网的网卡
iface eth0 inet static
address 192.168.1.133
netmask 255.255.255.0
gateway 192.168.1.1 //指定上一台服务器IP

3.配置内网的网卡
iface eth1 inet static
address 192.168.1.134
netmask 255.255.255.0

4.配置其它客户机网卡
iface eth0 inet static
address 192.168.1.135
netmask 255.255.255.0
gateway 192.168.1.133 //网关
阅读(1808) | 评论(0) | 转发(0) |
0

上一篇:perl中的

下一篇:mysql数据库优化参数

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