<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
<div class="moz-text-html" lang="x-western">
<div class="moz-text-flowed"
 style="font-family: -moz-fixed; font-size: 13px;" lang="x-western">Need
help.
<br>
<br>
Im trying to forward all traffic to a public server(A) to another
public server(B) except traffic to port 22. Found this on google but
cant get it to work. Could someone help me please.
<br>
Server A has one NIC server B has one NIC. Do i need 2 NICS in server
A.
<br>
<br>
#!/bin/sh
<br>
iptables -F
<br>
iptables -F INPUT
<br>
iptables -F OUTPUT
<br>
iptables -F FORWARD
<br>
iptables -X
<br>
iptables -F -t nat
<br>
iptables -P INPUT ACCEPT
<br>
iptables -P OUTPUT ACCEPT
<br>
iptables -P FORWARD ACCEPT
<br>
<br>
echo 1 > /proc/sys/net/ipv4/ip_forward
<br>
iptables -t nat -A PREROUTING -i eth0 --protocol tcp --destination-port
! 22 -j DNAT --to-destination "IP B"
<br>
iptables -t nat -A PREROUTING -i eth0 --protocol udp -j DNAT
--to-destination "IP B"
<br>
# END<br>
<br>
/etc/rc.d/init.d/iptables status<br>
Table: filter<br>
Chain INPUT (policy ACCEPT)<br>
num  target     prot opt source               destination<br>
<br>
Chain FORWARD (policy ACCEPT)<br>
num  target     prot opt source               destination<br>
<br>
Chain OUTPUT (policy ACCEPT)<br>
num  target     prot opt source               destination<br>
<br>
Table: mangle<br>
Chain PREROUTING (policy ACCEPT)<br>
num  target     prot opt source               destination<br>
<br>
Chain INPUT (policy ACCEPT)<br>
num  target     prot opt source               destination<br>
<br>
Chain FORWARD (policy ACCEPT)<br>
num  target     prot opt source               destination<br>
<br>
Chain OUTPUT (policy ACCEPT)<br>
num  target     prot opt source               destination<br>
<br>
Chain POSTROUTING (policy ACCEPT)<br>
num  target     prot opt source               destination<br>
<br>
Table: nat<br>
Chain PREROUTING (policy ACCEPT)<br>
num  target     prot opt source               destination<br>
1    DNAT       tcp  --  0.0.0.0/0            0.0.0.0/0           tcp
dpt:!22 to:"IP B"<br>
2    DNAT       udp  --  0.0.0.0/0            0.0.0.0/0          
to:"IP B"<br>
<br>
Chain POSTROUTING (policy ACCEPT)<br>
num  target     prot opt source               destination<br>
<br>
Chain OUTPUT (policy ACCEPT)<br>
num  target     prot opt source               destination<br>
<br>
<br>
<br>
/Morten.</div>
</div>
</body>
</html>