Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm designing a system with a Server PC with two nics running Centos 6 and a Sensor Device which runs a web server. The Sensor Device is connected directly to one of the nics of the Server PC. All that is in a box. The other nic is available from outside and can be connected to a switch.

Now, from my PC (or other client) I want to be able to access the Sensor Device web server, but I can't. I'm far from being an expert configuring networks like this. What I want:

When the Client PC request 192.168.1.100:8080 then the Server PC forwards that to 192.168.0.100:80 and then I can see it on the client PC. There are other answers about configuring two nics, bridges, bounding and other things but I don't think is the same situation.

If necessary I could use the same network for both the Server PC and the Sensor Device, but until now that doesn't help.

A diagram with the system is attached (using dropbox as I don't have enough votes, sorry).

https://dl.dropboxusercontent.com/u/50305647/Two%20nics%20diagram.png

Thanks in advance.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

It is quite simple.

  1. Allow forwarding on Server PC
  2. Add DNAT rules to Server PC

For CentOS it would be:

  1. Edit /etc/sysctl.conf and change

    net.ipv4.ip_forward = 0 to net.ipv4.ip_forward = 1, then sysctl -p

  2. iptables -t nat -A PREROUTING -p tcp --dport 8080 -j DNAT --to-destination 192.168.0.100:80

Also make sure that you have allowing rules in FORWARD chain of input table in iptables.

share|improve this answer
    
slimsuperhero THANKS A LOT! As you said is quite simple, but not for me! Thanks again! –  fjfeijoo May 23 '13 at 9:36
    
You are welcome! –  slimsuperhero May 23 '13 at 11:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.