Advertisement
metalx1000

upnpc port forwarding script

Dec 22nd, 2021
2,048
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.48 KB | None | 0 0
  1. #!/bin/bash
  2. ######################################################################
  3. #Copyright (C) 2021  Kris Occhipinti
  4. #https://filmsbykris.com
  5.  
  6. #This program is free software: you can redistribute it and/or modify
  7. #it under the terms of the GNU General Public License as published by
  8. #the Free Software Foundation, either version 3 of the License, or
  9. #(at your option) any later version.
  10.  
  11. #This program is distributed in the hope that it will be useful,
  12. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. #GNU General Public License for more details.
  15.  
  16. #You should have received a copy of the GNU General Public License
  17. #along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18. ######################################################################
  19.  
  20. echo "Getting Server Info..."
  21. server="$(upnpc -l | grep desc:|awk '{print $2}')"
  22.  
  23. ip="$(ip a|grep "inet "|awk '{print $2}'|cut -d\/ -f1|tail -n1)"
  24.  
  25. read -p "Interal Port: " internal
  26. read -p "External Port: " external
  27. read -p "Description: " description
  28.  
  29.  
  30. upnpc -u $server -d $external tcp
  31. echo "upnpc -u $server -a $ip $internal $external tcp"
  32. echo ": $(date +%s):0;upnpc -u $server -a $ip $internal  $external tcp" > $HOME/.zsh_history
  33. upnpc -u $server -a $ip $internal  $external tcp
  34.  
  35. echo -e "\n\nTo delete port run:\nupnpc -u $server -d $external tcp"
  36. echo ": $(date +%s):0;upnpc -u $server -d $external tcp" > $HOME/.zsh_history
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement