- 论坛徽章:
- 0
|
机器环境:
OS:linux as4
Soft Env:squid,iptables
NIC:eth0---->192.168.1.1 Lan (gateway)
eth1----->pppoe wan (2M)
eth2----->211.161.1.222 wan (2M)
问题:当wan双线同时接入是,host网络通,客户机无法上网,ping不通。
(memo:ip和mac作了安全处理)
1)、iptables 脚本:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
#ip 伪装
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j SNAT --to-source 211.161.1.222
#squid 透明代理#proxy starting
iptables -t nat -A PREROUTING -s 192.168.1.0/24 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
squid &
2)、显示网络信息
[root@proxy ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:E0:4C:8C 2:21
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::2e0:4cff:fe8c:d22d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3980763 errors:0 dropped:0 overruns:0 frame:0
TX packets:3813614 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1262398320 (1.1 GiB) TX bytes:3023368495 (2.8 GiB)
Interrupt:201 Base address:0xa000
eth1 Link encap:Ethernet HWaddr 00:11:5B:F3:74:82
inet6 addr: fe80::211:5bff:fef3:7481/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1895 errors:0 dropped:0 overruns:0 frame:0
TX packets:1877 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1041796 (1017.3 KiB) TX bytes:193600 (189.0 KiB)
Interrupt:177 Base address:0xa800
eth2 Link encap:Ethernet HWaddr 00:E0:4C:39:29:C1
inet addr:211.161.1.222 Bcast:211.161.1.243 Mask:255.255.255.224
inet6 addr: fe80::2e0:4cff:fe39:29cf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4029565 errors:1 dropped:0 overruns:0 frame:0
TX packets:4339964 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3016821941 (2.8 GiB) TX bytes:1282450449 (1.1 GiB)
Interrupt:185 Base address:0xa400
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:3354 errors:0 dropped:0 overruns:0 frame:0
TX packets:3354 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3953520 (3.7 MiB) TX bytes:3953520 (3.7 MiB)
ppp0 Link encap oint-to-Point Protocol
inet addr:58.33.105.222 P-t-P:218.1.60.205 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:7 errors:0 dropped:0 overruns:0 frame:0
TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:472 (472.0 b) TX bytes:21163 (20.6 KiB)
3、显示路由信息
#ip route show
218.1.60.205 dev ppp0 proto kernel scope link src 58.33.106.111
211.161.1.160/27 dev eth2 proto kernel scope link src 211.161.1.222
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.1
169.254.0.0/16 dev eth2 scope link
default via 218.1.60.205 dev ppp0
寻求解决方案:两条线能同时上网,带宽能够叠加,任意一条断线网络继续运行,网关自动调整为正常运行的那条线路。
希望linux高手给小弟指点,不胜感激!
|
|