U
U
utya2013-08-21 11:24:58
linux
utya, 2013-08-21 11:24:58

Redirect Centos

Good afternoon. There is a computer on centos so that all requests that go to its ip are redirected to another ip. How to do it quickly and beautifully. Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis Zaitsev, 2013-08-21
@utya

enable iptables
and add the line:
iptables -t nat -A PREROUTING -i eth0 -j DNAT --to-destination 192.168.1.1

D
Denis Zaitsev, 2013-08-21
@ZayDen

I gave you an example from my firewall (it really has more than two network interfaces), where the 192.168.1.0 mesh is connected to eth1
And do you need "Like peas against the wall" with one network card?
Try it, if it doesn't work out, you can "make a feint with your ears" :)
Add a virtual interface:
ifconfig add eth0:1 192.168.1.1 netmask 255.255.255.252 up
And send it back to the Internet:
iptables -t nat -A POSTROUTING -s 192.168. 1.1 -o eth0:1 -j SNAT --to-source 8.8.8.8 (where 8.8.8.8.is the IP address of your external eth0)

S
stavinsky, 2013-08-21
@stavinsky

Perhaps a more beautiful solution would be LVS. If, of course, there is access to the machine where the packets should be sent

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question