eth0 是wlan ,eth1 是 lan ,目标:实现 lan 内的电脑 通过 wan 连到公网 【centos 5.6】
设置就用到2部:
设置ip转发和打开核心对ip转发的支持,打开/etc/rc.d/rc.local 【与/etc/rc.local 同一个文件】 ,加入: echo 1 > /proc/sys/net/ipv4/ip_forward
命令行输入:iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
命令行输入:service iptables save
POSTROUTING 和 forward 的区别 , nat ?
iptables结构:

Linux下实现双网卡共享上网 ADSL拨号程序我们用 rp--pppoehttp://www.roaringpenguin.com/pengui...e_rp-pppoe.php
下载 rp-pppoe-3.8.tar.gz安装: tar zxvf rp-pppoe-3.8.tar.gz cd rp-pppoe-3.8. ./go
当出现 >>> Enter your PPPoE user name : 输入ADSL帐号的用户名当出现 >>> Enter the Ethernet interface connected to the ADSL modem For Solaris, this is likely to be something like /dev/hme0. For Linux, it will be ethn, where 'n' is a number. (default eth0): 输入 eth0 ,这是ADSL相连的网卡的名字当出现 >>> Enter the demand values (default no): 输入 no 当出现 >>> Enter the DNS inFORMation here: 输入相应的DNS服务器IP地址 (一般有2个)当出现 >>> Please enter your PPPoE password: 输入ADSL帐号的密码当出现 >>> Choose a type of firewall (0-2): 输入 0 ,不使用防火墙当出现 >>> Accept these settings and adjust configuration files (y/n)? 如果输入的信息正确,输入 y ,完成配置,否则,输入 n 重新输入。
使用: 拨好 pppoe-start
段开 pppoe-stop
查看 pppoe-status
ok ,下一步是修改一下系统配置找到/etc/sysconfig/networks文件,然后修改为 NETWORKING=yes HOSTNAME=proxy FORWARD_IPV4="yes" GATEWAY="ppp0" GATEWAYDEV=""
再修改如下配置 /etc/sysconfig/network-scripts/ifcfg-eth0文件: DEVICE=eth0 BOOTPROTO=static ONBOOT=yes
/etc/sysconfig/network-scripts/ifcfg-eth1文件: DEVICE=eth1 BROADCAST=192.168.0.255 IPADDR=192.168.0.1 NETMASK=255.255.255.0 NETWORK=192.168.0.0 ONBOOT=yes
最后设置ip转发和打开核心对ip转发的支持,打开/etc/rc.local文件,加入下面三行
echo 1 > /proc/sys/net/ipv4/ip_forward
ipchains -A forward -s 192.168.0.0/24 -d 0/0 -j MASQ
adsl-start &
最后一行的作用是让系统启动时自动拨号。

本文介绍如何在 CentOS 5.6 中配置 eth0 作为 WLAN 连接到公网,eth1 作为 LAN 实现局域网内计算机通过 eth0 访问互联网的方法。涉及 rp-pppoe 的安装与配置、IP 转发设置及 iptables 规则的添加。
1022

被折叠的 条评论
为什么被折叠?



