0

I need to enable NAT on my VM in iptables. I followed official debian instruction to configure it:

First of all, i created /etc/iptables.rules file with following content: *nat -A POSTROUTING -s 192.168.0.0/16 -o eth0 -j SNAT --to-source 46.4.120.218 COMMIT

After i use iptables-restore < /etc/iptables.rules manually, nat rules are added fine, everything works

But when i try to autoload iptables rules via file /etc/network/if-pre-up.d/iptables with following content eth interfaces disappear (i can see only loopback interface via ifconfig):

 #!/bin/sh
 /sbin/iptables-restore < /etc/iptables.rules

I tried to do the same on debian wheezy and this was working. In debian jessie this does not work. Is it my mistake, or bug?

P.S. I tried to move iptables script to if-up.d folder, eth interfaces are present in this case, but iptables rules are not applied.

  • Did you try to set post-up /etc/network/if-up.d/iptables in the section of that interface your /etc/network/interfaces? – Alexander Janssen Jun 14 '15 at 7:44
  • @AlexanderJanssen finally i resolved my problem via /etc/network/interfaces config with pre-up iptables-restore < /etc/iptables.rules line – avasin Jun 14 '15 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.