iptables trouble: nat with ip alias (virtual interface) not working

69

When you use virtual interfaces just use the option -d (destination), ignoring the option -i (interface)

Instead of:
iptables -t nat -A PREROUTING -i eth0 -d 25.25.25.26 -j DNAT --to-destination 172.16.2.1

use:
iptables -t nat -A PREROUTING -d 25.25.25.26 -j DNAT --to-destination

Work with iptables v1.4.14 in Debian

Share:
69
satya
Author by

satya

Updated on September 18, 2022

Comments

  • satya
    satya over 1 year

    I am calculating the day difference between two day using JavaScript. For some cases I am getting right result but some cases I cannot get the right result. My code is below:

    function caldate(){
           var difference=Math.abs((parseInt(document.getElementById('dayto').value)%7)-(parseInt(document.getElementById('dayfrom').value)%7))+1;
               alert(difference);
    }
    

    Here when day to is Sunday I am getting the wrong result. My plunkr code is here. I need to calculate the difference between two day including both selected days.

    • adeneo
      adeneo over 7 years
      Why are you changing the values with .abs() and %7, just compare the values
    • satya
      satya over 7 years
      @adeneo : suppose i selected from day=wedensday and to day=sunday the difference should 5 .
    • charlietfl
      charlietfl over 7 years
      it is 5 if you remove %7
    • adeneo
      adeneo over 7 years
      The values are numeric strings, just subtract them, as in value1 - value2, and if you want to avoid negative numbers wrap the whole thing in a Math.abs call
    • Emil S. Jørgensen
      Emil S. Jørgensen over 7 years
      Question: If dayfrom is greater than dayto, are we to assume another that day, but in next week?
  • Larssend
    Larssend about 7 years
    The FORWARD chain is not part of the nat table. Your proposed 'correction' will not be accepted by iptables -- it will give you an error message instead.
  • Larssend
    Larssend about 7 years
    Also, DNAT is only valid for PREROUTING and OUTPUT chains. Please avoid recommending anything that you don't really know.