Centos – how to add iptables rules for two NICs on CentOS(act as a gateway)

centosgatewaynicroute

I have a machine C with two NICs, namely eth0 and eth1, with CentOS 4.9 installed on it. Also I have a machine A connecting to C through eth0 and a machine B connecting to C through eth1. Now I want machine A to be in a subnet (e.g. 192.168.3.0/24) and machine B to be in another subnet (e.g. 192.168.4.0/24) and they could communicate with each other.

                  eth0         eth1
Machine A <---------> Machine C <---------> Machine B
           ...3.0/24             ...4.0/24

According to the answer of my previous question about this problem, I configured my eth0 and eth1:

/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.3.1
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet

/etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1
BOOTPROTO=static
IPADDR=192.168.4.1
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet

And configure Machine A (Windows XP) with 192.168.3.10, 192.168.3.1(gw), and Machine B (windows 7) with 192.168.4.10, 192.168.4.1(gw). I have enabled ip forwarding on machine C. Now, I haven't added any routes or iptables rules. I could ping 192.168.3.10 from machine B, but not vice vesa. Am i missing some routing rules? If yes, how to add these rules?

Any suggestions or tutorials or howtos will be appreciated.

Best Answer

A quick test:

Control Panel -> Windows Firewall (under System and Security, if you do that sort of thing). In the left pane, click 'Turn Windows Firewall On/Off', then turn off the Firewall in the right pane.

If you can ping it then, great... you can turn it back on, and allow ping by using the directions at http://www.sysprobs.com/enable-ping-reply-windows-7.

If that doesn't work, another quick test would be to shutdown iptables, just for troubleshooting purposes, of course. Even if you don't remember messing with it, it's worth testing...

sudo /etc/init.d/iptables stop
Related Topic