怎么用iptables配置共享互联网访问

由 bigmouth 在 06-05-2003 18:00 发表:

怎么用iptables配置共享互联网访问

底子太薄, 看了半天还是晕呼呼的. 那位高手直接针对我的个案给个具体说明吧, 谢谢了. 再不快点儿配好我们宿舍的要把我吃了! 以后有空再好好理解原理了.

我的情况是两块网卡, eth0内网192.168.0.8, eth1外网2xx.xx.xx.xx, 内网的机器都固定ip, 192.168.0.xx. 不准备对内网的机器作任何限制, 就是这样. 谢谢老大帮忙! 一定要好用就行.

还有, 为什么我不能直接执行iptables, 一定要写全路径?


由 pupilzeng 在 06-05-2003 18:11 发表:


第一步是打开forward

echo "1">/proc/sys/net/ipv4/ip_forward

第二步打开MASQUERADE

/sbin/iptables -t nat -A POSTROUTING -j MASQUERADE

如果没有iptables的话,有可能是你没有装这个工具。


Athlon XP1500+ +Jetway 866Pro(KT266A) +384RAM+Seaget U6 40G +Geforce MX400

Debian(sid)+XP


由 Snoopy 在 06-05-2003 18:19 发表:


forward和masquerade这两个在哪里有??还是自己建的?

建在哪个目录啊 ????目的是不是要它启动自己运行???


And then in the evening light, when the bars of freedom fall

I watch the two of you in the shadows on the wall

How in the darkness steals some of the choices from my hand

Then will I begin to under


由 lanmaster 在 06-05-2003 18:30 发表:


你可以直接编译/etc/rc.d/rc.local 这个文件。

echo 1>/proc/sys/net/ipv4/ip_forward

modprobe ip_tables

modprobe ip_nat_ftp

modprobe ip_conntrack

modprobe ip_conntrack_ftp

/sbin/iptables -t nat -A POSTROUTTIN -s 192.168.0.0/24 -j MASQUERADE

sysctl -1 net.ipv4.ip_forward=1

你这么做试一下吧。


成长中的菜鸟!

E-Mail:qcy_[email protected]

QQ :7118899


由 alessandro 在 06-14-2003 15:22 发表:


我不明白nat表不是内建了postrouting規則鍊吗?为什么还要自己用-A postrouting添加呢?


由 pupilzeng 在 06-14-2003 16:07 发表:


> quote: > > * * * > > 最初由 alessandro 发表
>
> 我不明白nat表不是内建了postrouting規則鍊吗?为什么还要自己用-A postrouting添加呢? > > * * *

这是添加规则

添加链是-N


Athlon XP1500+ +Jetway 866Pro(KT266A) +384RAM+Seaget U6 40G +Geforce MX400

Debian(sid)+XP


由 alessandro 在 06-14-2003 17:06 发表:


那么这句

iptables -t nat -A POSTROUTTIN -s 192.168.0.0/24 -j MASQUERADE

命令的含义是不是把POSTROUTTIN后面的-s 192.168.0.0/24 -j MASQUERADE规则添加到postrouting規則鍊里面


由 pupilzeng 在 06-14-2003 19:33 发表:


> quote: > > * * * > > 最初由 alessandro 发表
>
> **那么这句
>
> iptables -t nat -A POSTROUTTIN -s 192.168.0.0/24 -j MASQUERADE
>
> 命令的含义是不是把POSTROUTTIN后面的-s 192.168.0.0/24 -j MASQUERADE规则添加到postrouting規則鍊里面 ** > > * * *

yeah


Athlon XP1500+ +Jetway 866Pro(KT266A) +384RAM+Seaget U6 40G +Geforce MX400

Debian(sid)+XP


由 alessandro 在 06-15-2003 12:13 发表:


那我想请教你一下,POSTROUTTIN規則鍊本身里面都有一些什么啊?或者说如果我什么都不添加,那么POSTROUTTIN規則鍊里面都有些什么规则啊?


由 pupilzeng 在 06-15-2003 12:22 发表:


iptables -t nat -L 查看


Athlon XP1500+ +Jetway 866Pro(KT266A) +384RAM+Seaget U6 40G +Geforce MX400

Debian(sid)+XP


由 alessandro 在 06-15-2003 14:08 发表:


我现在用不了linux,所以问一下,如果我什么规则都不添加那么POSTROUTTIN規則鍊能做些什么?


由 pupilzeng 在 06-15-2003 16:24 发表:

这是我的

>iptables -L -t nat

Chain PREROUTING (policy ACCEPT)

target prot opt source destination

Chain POSTROUTING (policy ACCEPT)

target prot opt source destination

Chain OUTPUT (policy ACCEPT)

target prot opt source destination

默认的情况


Athlon XP1500+ +Jetway 866Pro(KT266A) +384RAM+Seaget U6 40G +Geforce MX400

Debian(sid)+XP


由 alessandro 在 06-15-2003 17:33 发表:


Published At
Categories with 服务器类
Tagged with
comments powered by Disqus