I cannot for the life of me figure out why the DROP winds up getting hit with outbound requests originating off my openvz based VPS.
I know it has to be something with how the packet isn't going directly outbound, or something, and I seem to be missing some basic thing here. I have tried various things, and the only way I can get it to work again is flushing the rules (iptables -F
)
The goal is to block all incoming traffic, except from one IP (1.2.3.4) and port 53/113 to everyone, and allow all outbound.
Here's output of iptables -L -n -v
- I can see DROP packet count go up when I try to curl outbound. (IPs slightly modified for privacy)
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
239 17668 ACCEPT all -- * * 1.2.3.4 0.0.0.0/0
118 11175 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp spt:53
3 174 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:53
17 1176 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:113
0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
2238 119K DROP all -- * * 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
889 56648 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0
this is from iptables-save
(IPs slightly modified for privacy)
# Generated by iptables-save v1.8.4 on Thu Dec 2 02:42:40 2021
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -s 1.2.3.4/32 -j ACCEPT
-A INPUT -p udp -m udp --sport 53 -j ACCEPT
-A INPUT -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 113 -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -j DROP
-A OUTPUT -j ACCEPT
COMMIT
# Completed on Thu Dec 2 02:42:40 2021
these are the interfaces (IPs slightly modified for privacy)
venet0: flags=211<UP,BROADCAST,POINTOPOINT,RUNNING,NOARP> mtu 1500
inet 127.0.0.1 netmask 255.255.255.255 broadcast 0.0.0.0 destination 127.0.0.1
inet6 2a00:d880:3:1::ad49:a3f2 prefixlen 128 scopeid 0x0<global>
inet6 2a00:d880:3:1::a639:a610 prefixlen 128 scopeid 0x0<global>
venet0:0: flags=211<UP,BROADCAST,POINTOPOINT,RUNNING,NOARP> mtu 1500
inet 81.1.1.1 netmask 255.255.255.255 broadcast 81.1.1.1 destination 81.1.1.1