Another routing/router Q - 8 NICs, v5.8

Issues related to configuring your network
Post Reply
TracyBaker
Posts: 2
Joined: 2015/01/15 19:45:46

Another routing/router Q - 8 NICs, v5.8

Post by TracyBaker » 2015/01/15 20:21:05

Yes, this is another question about setting up a CentOS machine as a router. I have done a lot of searching; finding various answers here and there, but so far nothing has worked. My set up is a little different.

This is in a VMware virtualized environment, which has no virtual router (at least mine doesn’t), so everything is connected to a vSwitch dedicated to these nine VMs. I do not want to connect this to any physical equipment, if at all possible.

I have eight Windows 7 machines, each set up very basically. I have one CentOS 5.8 (the ISO I had on hand -- I can upgrade if necessary) server with eight network cards installed, also set up very basically. Its only purpose is to be a router -- this arrangement will not communicate outside of the vSwitch it is connected to.

Each Windows machine is in a different subnet. For example, PC1 is in 192.168.1.0/24 and has an address of 192.168.1.50 and a gateway address of 192.168.1.254 – which is the network address assigned to eth0 on the CentOS server. PC2 is on 192.168.2.0/24 with the same IPs arrangement on the PC and the CentOS server (.50 on the PC, .254 on eth1). PC3 is on 192.168.3.0/24 – and so on so that there are eight subnets.

CentOS’s firewall is disabled because it really isn’t needed (I think) as I’m not talking to the outside world.

I have tried enabling the firewall and entering in (for each interface):
iptables –A FORWARD –i eth0 –j ACCEPT
iptables –A FORWARD –o eth0 –j ACCEPT

I also flushed and tried this:
iptables -A FORWARD -j ACCEPT

These did not work – so I turned the firewall back off:

net.ipv4.ip_forward is set to “1” (no quotes) in /etc/sysctl.conf and sysctl –p was executed. /sbin/sysctl net.ipv4.ip_forward displays a "1".

Each interface displays a “1” when I cat /proc/sys/net/ipv4/conf/eth{x}/forwarding (where {x} is an interface number 0 through 7).

Each PC can ping itself at its .50 address. The server can ping itself at all .254 addresses. Each PC can ping its default gateway address at the proper .254 address for its subnet.

As you may have guessed... The PCs cannot ping one another. It appears that the packets aren't being allowed to pass through the server. At this point, I just need pings to work -- later I may need other traffic types and protocols.

Help!?

Here's the result of the route command:

Code: Select all

Kernel IP routing table
Destination	Gateway		Genmask		Flags	Metric	Ref	Use	Iface
192.168.7.0	*		        255.255.255.0	U	1	0	0	eth6
192.168.6.0	*		        255.255.255.0	U	1	0	0	eth5
192.168.5.0	*		        255.255.255.0	U	1	0	0	eth4
192.168.4.0	*		        255.255.255.0	U	1	0	0	eth3
192.168.3.0	*		        255.255.255.0	U	1	0	0	eth2
192.168.2.0	*		        255.255.255.0	U	1	0	0	eth1
192.168.1.0	*		        255.255.255.0	U	1	0	0	eth0
192.168.8.0	*		        255.255.255.0	U	1	0	0	eth7
default		192.168.1.254	0.0.0.0		UG	0	0	0	eth0

TracyBaker
Posts: 2
Joined: 2015/01/15 19:45:46

Re: Another routing/router Q - 8 NICs, v5.8

Post by TracyBaker » 2015/02/09 20:34:57

188 views later, and no response...

Nevertheless, I solved the issue. Masquerading needs to been enabled for each interface that I want to use.

It was as easy as entering this for each interface and then telling CentOS to save the changes for next boot-up:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

I'm a Cisco guy, and therefor assumed that since the CentOS box "knew" about all directly connected networks it would work once ip forwarding was turned on -- like a Cisco router does (except for the ip forwarding part -- the router will do that automatically). It took me forever, and asking questions of the right people, to find out that I still needed to use NAT.

I'm now routing between all 8 NICs just peachy, now.

Post Reply