I currently have set up IPTables on my server to forward certain ports on a specific interface (venet0:1) to a second server, at a different IP. My config file looks like this:
# Generated by iptables-save v1.4.12 on Sat Jun 8 08:36:54 2013
*mangle
:PREROUTING ACCEPT [480:39372]
:INPUT ACCEPT [480:39372]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [339:44328]
:POSTROUTING ACCEPT [339:44328]
COMMIT
# Completed on Sat Jun 8 08:36:54 2013
# Generated by iptables-save v1.4.12 on Sat Jun 8 08:36:54 2013
*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A PREROUTING -i venet0:1 -p tcp -m state --state NEW,RELATED,ESTABLISHED -m tcp --dport 51315 -j DNAT --to-destination 76.xxx.xxx.xxx
-A PREROUTING -i venet0:1 -p tcp -m state --state NEW,RELATED,ESTABLISHED -m tcp --dport 27015:27020 -j DNAT --to-destination 76.xxx.xxx.xxx
-A PREROUTING -i venet0:1 -p tcp -m state --state NEW,RELATED,ESTABLISHED -m tcp --dport 25565:25570 -j DNAT --to-destination 76.xxx.xxx.xxx
-A PREROUTING -i venet0:1 -p tcp -m state --state NEW,RELATED,ESTABLISHED -m tcp --dport 7777 -j DNAT --to-destination 76.xxx.xxx.xxx
COMMIT
# Completed on Sat Jun 8 08:36:54 2013
# Generated by iptables-save v1.4.12 on Sat Jun 8 08:36:54 2013
*filter
:INPUT ACCEPT [86:6572]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [66:6912]
-A INPUT -i venet0:1 -j LOG
-A INPUT -i venet0:1 -p tcp -m tcp --dport 51315 -j ACCEPT
-A INPUT -i venet0:1 -p tcp -m tcp --dport 27015:27020 -j ACCEPT
-A INPUT -i venet0:1 -p tcp -m tcp --dport 25565:25570 -j ACCEPT
-A INPUT -i venet0:1 -p tcp -m tcp --dport 7777 -j ACCEPT
COMMIT
# Completed on Sat Jun 8 08:36:54 2013
(IP addresses concealed)
I've made sure that IPv4 forwarding is enabled, however when I do a lsmod
, nothing at all shows up.
I've also tried using modprobe
to add the iptables kernel modules, but nothing is found.
Could it be that the IPTables modules simply aren't installed, and that I need to recompile the kernel to install them?
When I try to connect on those ports, the connection is refused, as if iptables isn't even running.
I'm running Ubuntu 12.04 LTS on an OpenVZ VPS (hostname isn't actually hostname
).
Linux hostname 2.6.32-042stab076.7 #1 SMP Thu Apr 25 13:35:47 MSK 2013 x86_64 x86_64 x86_64 GNU/Linux
EDIT: OK, at the suggestion of one of the answers, I changed venet0:1
to venet0
. The behavior is still the same. A tcpdump of the port shows the following:
23:15:34.940437 IP 76.yyy.yyy.yyy.53802 > 192.xxx.xxx.xxx.51315: Flags [S], seq 3804882566, win 65535, options [mss 1460,nop,wscale 0,nop,nop,sackOK], length 0
23:15:34.940485 IP 76.yyy.yyy.yyy.53802 > 76.xxx.xxx.xxx.51315: Flags [S], seq 3804882566, win 65535, options [mss 1460,nop,wscale 0,nop,nop,sackOK], length 0
In the above, 76.yyy.yyy.yyy is the computer I am using to test the connection, 192.xxx.xxx.xxx is the IP of the server, and 76.xxx.xxx.xxx is the address of the server it's supposed to forward to. It seems to be forwarding the traffic somehow, except that the packets are zero-length and never get replied to. I also ran tcpdump on the receiving machine, and nothing showed up.