I am new to iptables and am confused on how I am supposed to set this up. It looks like I have 2 ethernet cards but I have 4 IP addresses. No prob there. In my network/interfaces, it looks like they are all on enp2s0f0. Can I just change 2 of them to be on interface enp2s0f1 assuming that the network comming into the server is the same as enp2s0f0? If in iptables you specify eth0 (in my case enp2s0f0) then how am I supposed to make rules for each IP?What I tried to do is specify the iface in network/interfaces as shown below however iptables shows the destination as anywhere when I specifically set it to enp2s0f0:0 and enp2s0f0iptables -A INPUT -i enp2s0f0 -p tcp --dports 80,443 -m state --state NEW,ESTABLISHED -j ACCEPTiptables -A OUTPUT -o enp2s0f0 -p tcp --sports 80,443 -m state --state ESTABLISHED -j ACCEPTiptables -A INPUT -i enp2s0f0:0 -p tcp --dports 80,443 -m state --state NEW,ESTABLISHED -j ACCEPTiptables -A OUTPUT -o enp2s0f0:0 -p tcp --sports 80,443 -m state --state ESTABLISHED -j ACCEPTHere is my ouput showing my interfaces...$ls /sys/class/netenp2s0f0  enp2s0f1  lo$cat /etc/network/interfacesauto loiface lo inet loopback# The primary network interfaceauto enp2s0f0iface enp2s0f0 inet static        address xx.xx.xx.76        netmask 255.255.255.0        network xx.xx.xx.0        broadcast xx.xx.xx.255        gateway xx.xx.xx.1auto enp2s0f0:0iface enp2s0f0:0 inet static        address xx.xx.xx.77        netmask 255.255.255.0        network xx.xx.xx.0        broadcast xx.xx.xx.255auto enp2s0f0:1iface enp2s0f0:1 inet static        address xx.xx.xx.78        netmask 255.255.255.0        network xx.xx.xx.0        broadcast xx.xx.xx.255auto enp2s0f0:2iface enp2s0f0:2 inet static        address xx.xx.xx.79        netmask 255.255.255.0        network xx.xx.xx.0        broadcast xx.xx.xx.255l
How to set different rules to multiple IPs on the same interface?
linux;networking;iptables;firewall;network interface
I quote some lines from man iptables:[!] -p, --protocol protocol       The  protocol  of  the rule or of the packet to check.[!] -s, --source address[/mask][,...]       Source specification. Address can be either a network name, a hostname,        a network IP address (with /mask),  or  a  plain  IP  address.  [!] -d, --destination address[/mask][,...]       Destination  specification.I consider the case you have two interfaces with two static IP each, since you can do that.So, if you want to match specific IPs, you can rearrange your rules:iptables -A INPUT  -i enp2s0f0 -p tcp -s 0.0.0.0 -d <IP> --dports 80,443 -m state --state NEW,ESTABLISHED -j ACCEPTiptables -A OUTPUT -o enp2s0f0 -p tcp -s <IP> -d 0.0.0.0 --sports 80,443 -m state --state ESTABLISHED -j ACCEPTiptables -A INPUT  -i enp2s0f1 -p tcp -s 0.0.0.0 -d <IP> --dports 80,443 -m state --state NEW,ESTABLISHED -j ACCEPTiptables -A OUTPUT -o enp2s0f1 -p tcp -s <IP> -d 0.0.0.0 --sports 80,443 -m state --state ESTABLISHED -j ACCEPTOf course you have to change <IP> with your machine IP(s). If you want to allow connections only from/to certain IPs change 0.0.0.0 too.