There is a nice answer on how to connect to a certain wifi network using the interfaces file:
Next, I suggest you edit /etc/network/interfaces:
auto lo iface lo inet loopback auto wlan0 iface wlan0 inet static address 192.168.1.150 netmask 255.255.255.0 gateway 192.168.1.1 wpa-essid MYESSID12345 wpa-psk MYPASSWORD$1234567
Of course, substitute your details here. Restart the interface:
sudo ifdown wlan0 && sudo ifup -v wlan0
Test:
ping -c3 www.ubuntu.com
If you get ping results, you are connected.
I had this working but now I want to try this on different computer where wlan0 is changed to wlp3s0. How do I modify the interfaces file to utilize wlp3s0 instead of wlan0? Replacing the word wlan0 with wlp3s0 but it didn't work. Here is output from ifconfig
bakalolo@User1:/etc/network$ ifconfig
enp0s20u5c4i2 Link encap:Ethernet HWaddr de:a4:ca:76:cf:5b
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:850 errors:0 dropped:0 overruns:0 frame:0
TX packets:850 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:71483 (71.4 KB) TX bytes:71483 (71.4 KB)
wlp3s0 Link encap:Ethernet HWaddr 18:65:90:d7:20:45
inet addr:192.168.0.102 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::f431:c4c2:b266:ec4e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:423 errors:0 dropped:0 overruns:0 frame:0
TX packets:625 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:134835 (134.8 KB) TX bytes:147654 (147.6 KB)
It is certainly necessary to declare the correct interface, in this case wlp3s0. Moreover, it is necessary to specify a static address in the range of the network you are trying to connect to; for instance, the file you are attempting to copy is in the range of 192.168.1.x. As you can see from your current
ifconfig
, the address you have now is in the range of 192.168.0.x. A wireless router in the 192.168.0.x neighborhood isn’t going to give you an address of 192.168.1.150.It is also crucial to select a static IP address that is outside the range used for DHCP. Please see this example of a typical router administration page:
As you see, in this example, the router assigns DHCP addresses from 192.168.1.110 to 192.168.1.159. Therefore, any static IP addresses should be selected either in the range 192.168.1.2 to 192.168.1.109 or else in the range of 192.168.1.150 to 192.168.1.253.
It is important not to specify a static IP address that collides with an existing device. If you know or can find out the range used in the router, your course is clear. If you do not, you are better off to stick to DHCP. Then, I’d suggest that your file read: