iprange -dst-range on vpn
by cokiere from LinuxQuestions.org on (#5SQ0E)
hello
i don't understand the difference between option -d and iprange
example:
this works
-A OUTPUT -p udp -m udp -d 103.107.197.0/24 --dport 1194 -j ACCEPT
this doesn't work
-A OUTPUT -p udp -m udp -m iprange --dst-range 37.120.217.84-37.120.217.170 --dport 1194 -j ACCEPT
my iptables:
*mangle
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Set a default DROP policy.
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT DROP [0:0]
# Allow basic INPUT traffic.
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT
-A INPUT -p icmp --icmp-type 8 -m conntrack --ctstate NEW -j ACCEPT
# Allow basic OUTPUT traffic.
-A OUTPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -o lo -j ACCEPT
-A OUTPUT -p icmp -j ACCEPT
# Allow traffic to the OpenVPN server and via the tunnel.
-A OUTPUT -o proton0 -j ACCEPT
-A OUTPUT -p udp -m udp -d 103.107.197.0/24 --dport 1194 -j ACCEPT
-A OUTPUT -p udp -m udp -d 103.107.197.0/24 --dport 5060 -j ACCEPT
-A OUTPUT -p udp -m udp -d 103.107.197.0/24 --dport 9050 -j ACCEPT
-A OUTPUT -p udp -m udp -d 103.107.197.0/24 --dport 4569 -j ACCEPT
# Reject everything else.
-A INPUT -m conntrack --ctstate INVALID -j DROP
-A INPUT -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -j REJECT --reject-with icmp-port-unreachable
-A OUTPUT -j REJECT --reject-with icmp-port-unreachable
COMMIT
i don't understand the difference between option -d and iprange
example:
this works
-A OUTPUT -p udp -m udp -d 103.107.197.0/24 --dport 1194 -j ACCEPT
this doesn't work
-A OUTPUT -p udp -m udp -m iprange --dst-range 37.120.217.84-37.120.217.170 --dport 1194 -j ACCEPT
my iptables:
*mangle
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Set a default DROP policy.
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT DROP [0:0]
# Allow basic INPUT traffic.
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT
-A INPUT -p icmp --icmp-type 8 -m conntrack --ctstate NEW -j ACCEPT
# Allow basic OUTPUT traffic.
-A OUTPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -o lo -j ACCEPT
-A OUTPUT -p icmp -j ACCEPT
# Allow traffic to the OpenVPN server and via the tunnel.
-A OUTPUT -o proton0 -j ACCEPT
-A OUTPUT -p udp -m udp -d 103.107.197.0/24 --dport 1194 -j ACCEPT
-A OUTPUT -p udp -m udp -d 103.107.197.0/24 --dport 5060 -j ACCEPT
-A OUTPUT -p udp -m udp -d 103.107.197.0/24 --dport 9050 -j ACCEPT
-A OUTPUT -p udp -m udp -d 103.107.197.0/24 --dport 4569 -j ACCEPT
# Reject everything else.
-A INPUT -m conntrack --ctstate INVALID -j DROP
-A INPUT -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -j REJECT --reject-with icmp-port-unreachable
-A OUTPUT -j REJECT --reject-with icmp-port-unreachable
COMMIT