Skip to content

Instantly share code, notes, and snippets.

@u1735067
Created December 30, 2018 16:15
Show Gist options
  • Save u1735067/acab3463f23fdc478f7c002a08b71718 to your computer and use it in GitHub Desktop.
Save u1735067/acab3463f23fdc478f7c002a08b71718 to your computer and use it in GitHub Desktop.
netcat, netstat, iptables reject
https://unix.stackexchange.com/questions/457670/netcat-how-to-listen-on-a-tcp-port-using-ipv6-address
https://github.com/craSH/socat/blob/master/EXAMPLES
https://serverfault.com/questions/353985/socat-show-incoming-connections
socat -d -d -6 tcp6-listen:5555 stdio
socat -d -d -6 tcp-connect:[ipv6]:88 stdio
https://stackoverflow.com/questions/5106674/error-address-already-in-use-while-binding-socket-with-address-but-the-port-num
http://www.softlab.ntua.gr/facilities/documentation/unix/unix-socket-faq/unix-socket-faq-2.html#time_wait
netstat -Waptun |grep 5555
ss -aptun | grep 5555
https://unix.stackexchange.com/questions/124624/what-a-input-j-reject-reject-with-icmp-host-prohibited-iptables-line-does-ex
https://github.com/MaxKellermann/ferm/issues/10
https://linux.die.net/man/8/iptables
iptables -j REJECT -h | grep "Valid reject types" -A 17
icmp-net-unreachable ICMP network unreachable
net-unreach alias
icmp-host-unreachable ICMP host unreachable
host-unreach alias
icmp-proto-unreachable ICMP protocol unreachable
proto-unreach alias
icmp-port-unreachable ICMP port unreachable (default)
port-unreach alias
icmp-net-prohibited ICMP network prohibited
net-prohib alias
icmp-host-prohibited ICMP host prohibited
host-prohib alias
tcp-reset TCP RST packet
tcp-rst alias
icmp-admin-prohibited ICMP administratively prohibited (*)
admin-prohib alias
iptables -I
https://linux.die.net/man/8/ip6tables
ip6tables -j REJECT -h | grep "Valid reject types" -A 11
icmp6-no-route ICMPv6 no route => Network is unreachable
no-route alias
icmp6-adm-prohibited ICMPv6 administratively prohibited => Permission denied
adm-prohibited alias
icmp6-addr-unreachable ICMPv6 address unreachable => No route to host
addr-unreach alias
icmp6-port-unreachable ICMPv6 port unreachable => Connection refused
port-unreach alias
tcp-reset TCP RST packet => Connection refused
iptables -I INPUT 1 -p tcp --dport 70 -j REJECT --reject-with icmp-net-unreachable => Network is unreachable
iptables -I INPUT 1 -p tcp --dport 71 -j REJECT --reject-with icmp-host-unreachable => No route to host
iptables -I INPUT 1 -p tcp --dport 72 -j REJECT --reject-with icmp-proto-unreachable => Protocol not available
iptables -I INPUT 1 -p tcp --dport 73 -j REJECT --reject-with icmp-port-unreachable => Connection refused
iptables -I INPUT 1 -p tcp --dport 74 -j REJECT --reject-with icmp-net-prohibited => Network is unreachable
iptables -I INPUT 1 -p tcp --dport 75 -j REJECT --reject-with icmp-host-prohibited => No route to host
iptables -I INPUT 1 -p tcp --dport 76 -j REJECT --reject-with icmp-admin-prohibited => No route to host
iptables -I INPUT 1 -p tcp --dport 77 -j REJECT --reject-with tcp-reset => Connection refused
ip6tables -I INPUT 1 -p tcp --dport 70 -j REJECT --reject-with icmp6-no-route => Network is unreachable
ip6tables -I INPUT 1 -p tcp --dport 71 -j REJECT --reject-with icmp6-adm-prohibited => Permission denied
ip6tables -I INPUT 1 -p tcp --dport 72 -j REJECT --reject-with icmp6-addr-unreachable => No route to host
ip6tables -I INPUT 1 -p tcp --dport 73 -j REJECT --reject-with icmp6-port-unreachable => Connection refused
ip6tables -I INPUT 1 -p tcp --dport 74 -j REJECT --reject-with tcp-reset => Connection refused
for i in $(seq 70 77); do telnet ipv4 $i | grep telnet; done
for i in $(seq 70 74); do telnet ipv6 $i | grep telnet; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment