Advertisement
Guest User

Quicknet script

a guest
Feb 27th, 2011
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # quicknet
  4. #
  5. # quickly set up for networking on specified interface & IP
  6. #
  7. # Date Who What/notes
  8. # ----------- ----------------------- ------------------------------------
  9. # 26 Feb 2010 Aaron R. Kulkis Original version
  10. #
  11. #
  12. # Essence of program:
  13. # prompt and read INTERFACE
  14. # ifup $INTERFACE
  15. # ifconfig
  16. # prompt and read IP
  17. # ifconfig $INTERFACE $IP
  18. # ifconfig
  19. # prompt and read ROUTER
  20. # route add $ROUTER $INTERFACE
  21. # route
  22. # route add default gw $ROUTER $INTERFACE
  23. # route
  24. # ping ROUTER (confirm connection to router)
  25. # ping 8.8.8.8 (Google open DNS host, confirms gateway operation))
  26. # ping www.google.com (confirms DNS operation)
  27. #
  28. #
  29.  
  30. SELF=`basename $0`
  31.  
  32. #
  33. #### GET INTERFACE ##################
  34. #
  35.  
  36. printf "Use which interface ? "
  37. read INTERFACE
  38.  
  39. printf "execute ifup $INTERFACE ?"
  40. read RESPONSE
  41. case RESPONSE in
  42. y* | Y* )
  43. set -x
  44. ifup $INTERFACE
  45. ifconfig $INTERFACE
  46. set +x
  47. ;;
  48. esac
  49.  
  50.  
  51. #
  52. #### GET ADDRESS ##################
  53. #
  54.  
  55. printf "What IP address for $INTERFACE ? "
  56. read IP
  57.  
  58. printf "\nAttempting to configure $INTERFACE\n"
  59. set -x ; ifconfig $INTERFACE $IP ; set +x
  60.  
  61. printf "\nPress return key" ; read A
  62. set -x ; ifconfig $INTERFACE ; set +x
  63.  
  64. #
  65. #### DEFINE ROUTER ##################
  66. #
  67.  
  68. printf "What is the name or IP address of the router/gateway? "
  69. read ROUTER
  70.  
  71. printf "specifying path to router $ROUTER\n"
  72. set -x ; route add $ROUTER $INTERFACE ; set +x
  73.  
  74. printf "\nPress return key" ; read A
  75. printf "Verifying route added to route table\n"
  76. set -x ; route ; set +x
  77.  
  78. printf "defining $ROUTER as the gateway.\n"
  79. set -x ; route add default gw $ROUTER $INTERFACE ; set +x
  80.  
  81. printf "\nPress return key" ; read A
  82. printf "Verify route added to route table\n"
  83. set -x ; route ; set +x
  84.  
  85. #
  86. #### VERIFY ROUTE COMPLETE ##################
  87. #
  88.  
  89. printf "Verifiny that route table complete:\n"
  90. set -x ; route ; set +x
  91.  
  92. printf "test local network with 3 pings: "
  93. set -x; ping -c 3 $ROUTER ; set +x
  94.  
  95. printf "test routing by pinging Google public DNS servers 3 times each\n"
  96. set -x
  97. ping -c 3 8.8.8.8
  98. ping -c 3 8.8.4.4
  99. set +x
  100.  
  101. printf "Testing DNS functionality:\n pinging www.google.com 3 times\n"
  102. set -x; ping -c 3 www.google.com ; set +x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement