Advertisement
metalx1000

Server with loopback only using iptables

Apr 14th, 2025 (edited)
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.66 KB | None | 0 0
  1. # list iptables rules
  2. sudo iptables -L
  3.  
  4. # clear iptables rules
  5. sudo iptables -F INPUT
  6.  
  7. #start server
  8. busybox nc -l -p 8888
  9.  
  10. # connect with client
  11. busybox nc localhost:8888
  12. busybox nc 127.0.0.1:8888
  13. busybox nc 192.168.1.158:8888
  14.  
  15. # block incoming traffic on port 8888
  16. sudo iptables -A INPUT -p tcp --dport 8888 -j REJECT
  17.  
  18. #allow loopback
  19. sudo iptables -A INPUT -i lo -j ACCEPT
  20.  
  21. #start server
  22. busybox nc -l -p 8888
  23.  
  24. # connect with client - now only working with localhost
  25. busybox nc localhost:8888
  26. busybox nc 127.0.0.1:8888
  27. busybox nc 192.168.1.158:8888
  28.  
  29.  
  30.  
  31. # clear iptables rules
  32. sudo iptables -F INPUT
  33. # list iptables rules
  34. sudo iptables -L
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement