|
|
菜鸟提问: 配置NAT
服务器(RHEL AS3):
eth0: 192.168.0.254 接内网(192.168.0.10--192.168.0.50)
eth1: 192.168.1.254 接外网(ADSL)[宽带路由器(192.168.1.1)]
执行脚步fw.sh,内容如下(网上抄的):
#!/bin/bash
echo 1 > /proc/sys/net/ipv4/ip_forward
modprobe ip_nat_ftp
modprobe iptable_nat
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth1 -j MASQUERADE
运行以下测试命令得到如下结果:
# iptables -nL
Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain RH-Firewall-1-INPUT (2 references)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 icmp type 255
ACCEPT esp -- 0.0.0.0/0 0.0.0.0/0
ACCEPT ah -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
# iptables -t nat -L -v
Chain PREROUTING (policy ACCEPT 3459 packets, 166K bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 MASQUERADE all -- any eth1 192.168.0.0/24 anywhere
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
0.0.0.0 192.168.1.254 0.0.0.0 UG 0 0 0 eth1
不知道为何会出现
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
好像是网关不对,不知该怎么改?
还有如下错误信息,好像是iptables的写法有误:
# tail /var/log/messages
May 26 13:27:39 kernel: Neighbour table overflow.
May 26 13:27:45 kernel: NET: 253 messages suppressed.
May 26 13:27:45 kernel: Neighbour table overflow.
May 26 13:27:48 kernel: NET: 120 messages suppressed.
May 26 13:27:48 kernel: Neighbour table overflow.
May 26 13:28:49 kernel: NET: 249 messages suppressed.
May 26 13:28:49 kernel: Neighbour table overflow.
May 26 13:28:49 last message repeated 9 times
May 26 13:28:55 kernel: NET: 106 messages suppressed.
May 26 13:28:55 kernel: Neighbour table overflow.
# arp -an |wc -l
1016 <-- 不确定,有时大,有时小.范围(1--1500)
就是这些了,大家帮帮我啊,我不想用WINDOWS啊
顺带敷上客户机设置
客户机(WinXP):
C:\WINDOWS\system32>ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . : cp-sh3
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Unknown
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
Ethernet adapter 本地连接:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Broadcom 440x 10/100 Integrated Cont
roller
Physical Address. . . . . . . . . : 00-12-3F-D4-8F-C8
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : 192.168.0.42
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.0.254
DNS Servers . . . . . . . . . . . : 192.168.1.1
202.96.209.6
202.96.209.133
NetBIOS over Tcpip. . . . . . . . : Disabled
C:\WINDOWS\system32>ping 192.168.0.254
Pinging 192.168.0.254 with 32 bytes of data:
Reply from 192.168.0.254: bytes=32 time<1ms TTL=64
Ping statistics for 192.168.0.254:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
C:\WINDOWS\system32>ping 192.168.1.254
Pinging 192.168.1.254 with 32 bytes of data:
Reply from 192.168.1.254: bytes=32 time<1ms TTL=64
Ping statistics for 192.168.1.254:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
C:\WINDOWS\system32>ping 192.168.1.1
Pinging 192.168.1.1 with 32 bytes of data:
Reply from 192.168.1.1: bytes=32 time<1ms TTL=63
Ping statistics for 192.168.1.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms |
|