While Blaz assumed you couldn't get Internet Access from connected LAN hosts, I'm not so sure your question isn't that you are having trouble connecting to the Internet on the Linux box itself...
If this is the case, you need to look at your routing tables:
# route
Your rules are actually simple... you want to direct anything on the LAN to eth1 (NIC2) and anything NOT for the LAN to eth0 (NIC1). Since examples work best, lets assume your WAN IP address is 1.2.3.4 & your assigned gateway is 1.2.3.1. Further, let's assume your LAN IP is 10.0.0.1/24.
What you WANT your routing table to look like is this:
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.0.0 * 255.255.255.0 U 0 0 0 eth1
169.254.0.0 * 255.255.0.0 U 0 0 0 eth1
default 1.2.3.1 0.0.0.0 UG 0 0 0 eth0
In CENTOS, you'll manage these settings in the following files (for reboot)
- /etc/sysconfig/network
GATEWAY=1.2.3.1
- /etc/sysconfig/network-scr
IPADDR=1.2.3.4
etc....
- /etc/sysconfig/network-scr
IPADDR=10.0.0.1
etc...
Once the routing tables are setup, THEN you can add the forwarding commands listed above.
Just my thoughts in case the issue was routing for the Linux box vs. connecting clients....
Dan
IT4SOHO
Main Topics
Browse All Topics





by: BlazPosted on 2009-06-30 at 23:45:33ID: 24751948
In general these are the steps to get forwarding working:
ard
1. enable ip forwarding on the machine:
echo 1 > /proc/sys/net/ipv4/ip_forw
2. make sure that NATing is configured (MASQUERADE or SNAT):
iptables -t nat -I POSTROUTING -i eth0 -o ppp0 -j MASQUERADE
3. make sure that you allow forwarding traffic in iptables rules:
iptables -I FORWARD -i eth0 -j ACCEPT
iptables -I FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
Thats about it.
Post a comment if you have troubles with any of these steps