shokti

ubuntu network config files and command

Sep 25th, 2012
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.90 KB | None | 0 0
  1. network ip address settings in /etc/network/interfaces:
  2. sudo nano /etc/network/interfaces
  3.  
  4. to start interface on startup:
  5. auto eth0
  6.  
  7. static ip sample:
  8. iface eth0 inet static
  9. address 192.168.1.5
  10. netmask 255.255.255.0
  11. broadcast 192.168.1.255
  12. network 192.168.1.0
  13. gateway 192.168.1.254
  14.  
  15. dhcp ip sample:
  16. iface eth0 inet dhcp
  17.  
  18. to change hosts settings, edit /etc/hosts:
  19. sudo nano /etc/hosts
  20. to change hostname, edit /etc/hostname:
  21. sudo nano /etc/hostname
  22. to change dns resolution settings, edit /etc/resolv.conf
  23. sudo nano /etc/resolv.conf
  24. add dns server ip address:
  25. nameserver 8.8.8.8
  26. nameserver 8.8.4.4
  27.  
  28. to turn off interface:
  29. sudo ifdown eth0
  30.  
  31. to turn on interface:
  32. sudo ifup eth0
  33.  
  34. to list active interface ip address:
  35. ifconfig
  36.  
  37. to list all(active/inactive) interface ip address:
  38. ifconfig -a
  39.  
  40. to restart network service:
  41. sudo /etc/init.d/networking restart
  42.  
  43. to list used ports:
  44. netstat -an |more
  45. or
  46. netstat -an |less
  47.  
  48. if you are using desktop and you want to use the network config files instead of the network manager:
  49. sudo apt-get remove network-manager network-manager-gnome
  50.  
  51. after removing network manager, when you have problems with dns resolution from /etc/resolv.conf then dns ip and dns search in the interfaces file:
  52.  
  53. dns-nameservers 8.8.8.8 8.8.4.4
  54. dns-search yourdomain.com
  55.  
  56. ===================================================================================================
  57. Wireless adapter or card:
  58.  
  59. wireless uitlities:
  60. sudo apt-get install wireless-tools
  61.  
  62.  
  63. to use windows wireless driver in ubuntu:
  64.  
  65. verify the ndiswrapper-utils version before install:
  66. sudo apt-cache search ndiswrapper-utils
  67.  
  68. install ndiswrapper:
  69. sudo apt-get install ndiswrapper-common ndiswrapper-utils-1.9
  70.  
  71. Copy .INF and .SYS files from driver:
  72.  
  73. Install Driver:
  74. sudo ndiswrapper -i driver-name.inf
  75.  
  76. Verify if Driver is installed:
  77. ndiswrapper -l
  78.  
  79. install ndiswrapper driver:
  80. sudo modprobe ndiswrapper
  81.  
  82. Verify wireless interface:
  83. iwconfig
  84.  
  85. Make sure your driver get loaded each time you boot your computer:
  86. sudo ndiswrapper -m
  87.  
  88. config in /etc/network/interfaces:(using WEP)
  89. auto wlan0
  90. iface wlan0 inet dhcp
  91. wireless-essid mywifi
  92. wireless-key 0123456789ABCDEF0123456789
  93. wireless-channel 11
  94. wireless-mode managed
  95.  
  96. Use WPA and WPA2:
  97. install wpasupplicant:
  98. sudo apt-get install wpasupplicant wpagui
  99.  
  100. scan your network:
  101. sudo iwlist wlan0 scan
  102.  
  103. Configure Wireless card for WPA authentication:
  104. sudo nano /etc/wpa_supplicant.conf
  105.  
  106. add in the config file:
  107. network={
  108. ssid="YOUR-NETWORK-ESSID"
  109. proto=WPA
  110. key_mgmt=WPA-PSK
  111. pairwise=TKIP
  112. group=TKIP
  113. psk="YOUR-PASSWORD"
  114. }
  115.  
  116. Configure Wireless card for WPA2 authentication:
  117. sudo nano /etc/wpa_supplicant.conf
  118.  
  119. add in the config file:
  120. network={
  121. ssid="YOUR-NETWORK-ESSID"
  122. proto=RSN
  123. key_mgmt=WPA-PSK
  124. pairwise=CCMP TKIP
  125. group=CCMP TKIP
  126. psk="YOUR-PASSWORD"
  127. }
  128.  
  129. Connect to network:
  130. sudo wpa_supplicant -d -c/etc/wpa_supplicant.conf -iwlan0 -Dwext
  131.  
  132. assign IP address using DHCP:
  133. sudo ifconfig wlan0 up
  134. sudo dhclient wlan0
  135.  
  136. If every thing works as expected, you can start wpa_supplicant without -d option i.e replace -d by -B for the deamon mode:
  137.  
  138. sudo wpa_supplicant -B -c/etc/wpa_supplicant.conf -iwlan0 -Dwext
  139.  
  140. ===================================================================================================
  141. assign IP Address to a specific interface (eth1) on the fly:
  142. sudo ip addr add 192.168.50.5 dev eth1
  143.  
  144. check ip address:
  145. sudo ip addr show
  146.  
  147. remove an assigned IP address from the given interface (eth1):
  148. sudo ip addr del 192.168.50.5/24 dev eth1
  149.  
  150. enables a network interface:
  151. sudo ip link set eth1 up
  152.  
  153. disables a network interface:
  154. sudo ip link set eth1 down
  155.  
  156. check the routing table:
  157. sudo ip route show
  158.  
  159. add Static routes:
  160. sudo ip route add 10.10.20.0/24 via 192.168.50.100 dev eth0
  161.  
  162. remove assigned static route:
  163. sudo ip route del 10.10.20.0/24
  164.  
  165. add the persistence Static routes:
  166. sudo nano /etc/network/interfaces
  167. ---------------------------------
  168. auto eth0
  169. iface eth0 inet static
  170. address 192.168.50.2
  171. netmask 255.255.255.0
  172. gateway 192.168.50.100
  173. #########{Static Route}###########
  174. up ip route add 10.10.20.0/24 via 192.168.50.100 dev eth0
  175. ----------------------------------
  176. add default gateway on the fly:
  177. sudo ip route add default via 192.168.50.100
  178.  
  179. create virtual network interface:
  180. sudo gedit /etc/network/interfaces
  181. ----------------------------------
  182. auto eth0
  183. iface eth0 static
  184. address 192.168.x.x
  185. netmask 255.255.x.x
  186. gateway 291.168.x.x
  187. auto eth0:0
  188. iface eth0:0 static
  189. address 192.168.xx.xx
  190. netmask 255.255.xx.xx
  191. gateway 192.168.xx.xx
  192. ----------------------------------
Advertisement
Add Comment
Please, Sign In to add comment