LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook
User Name
Password
Linux - Laptop and Netbook Having a problem installing or configuring Linux on your laptop? Need help running Linux on your netbook? This forum is for you. This forum is for any topics relating to Linux and either traditional laptops or netbooks (such as the Asus EEE PC, Everex CloudBook or MSI Wind).

Notices


Reply
  Search this Thread
Old 02-23-2017, 01:26 PM   #1
TBotNik
Member
 
Registered: May 2016
Location: Greenville, TX
Distribution: Kubuntu 18.04
Posts: 796

Rep: Reputation: Disabled
Wifi Connection {BASH}


All,

As most of you know Ubuntu's Network Manager is a joke, not a real tool. Therefore to get connections made, we have to resort to bash scripts that can actually work, in making connections.

I wrote the following bash, originally to find and link the remote tethering from my phone. Worked well calling "My Stylo", but now I also have the "netis" wifi router in the mix, which it does not correctly connect to.

I get the "Connected" popup, but it will not ping. Think I'm missing the key/password for the essid but haven't found out how to pass that in.

Additionally I want the script to see if "netis" is available then connect there, or else connect "My Stylo". Haven't figured out how to query what's available

Wifi-Start.sh
Code:
#! /bin/bash

# Files needed for networking are:
#  /etc/network/interfaces
#  /etc/iptables
#  /etc/resolv.conf
#  /etc/sysctl.conf

# Find current wlan0 channel with
# iwlist wlan0 channel;

# Run the commands to start network passthru
#service networking restart;
#service network-manager restart;
ifconfig wlan0 down;
iwconfig wlan0 ap '78:92:9c:25:b5:d0';
#iwconfig wlan0 essid "My Stylo";
#iwconfig wlan0 freq 2.412;
iwconfig wlan0 essid "netis";
iwconfig wlan0 freq 2.437;
dhclient wlan0;

# Additional commands
sysctl -w net.ipv4.ip_forward=1;
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE;

ping -c 3 www.google.com
Additionally I had to write this bash script to connect on eth0 "wired". Originally I was calling/restarting network-manager, but when the wifi routers are also available, they try connecting, fail and the conflicts makes eth0 not work correctly, so had to disable those calls.

Code:
#! /bin/bash
# Script to start wired networking

echo "Shutting down IFACE and Networking!";
ifconfig eth0 down;
#service networking stop;
#service network-manager stop;

# Run the commands to restart dhcp client and assign IP Address
echo "Starting IFACE and Networking!";
#service networking 3start;
#service network-manager start;
ifconfig eth0 up;

echo "Starting DHC Client!";
dhclient eth0;
ping -c 3 www.google.com;

# Finish
Would appreciate help getting these working right so I have total control over my laptop. Right now I can only work from the wired port, so not able to be mobile with the laptop, which is it's whole purpose.

Cheers!

TBNK
 
Old 02-23-2017, 01:58 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,784

Rep: Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937
If you do not like network manager you can try wicd but it does not have all the features.

Below is a list of the wireless tools you can use to query and configure your wireless adapter. What you are missing is wpa_suppliciant which allows you to associate with an access point that uses WPA encryption. Once associated you can use your DHCP client to request an IP address.

https://en.wikipedia.org/wiki/Wireless_tools_for_Linux
 
Old 02-23-2017, 09:16 PM   #3
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,386
Blog Entries: 28

Rep: Reputation: 6164Reputation: 6164Reputation: 6164Reputation: 6164Reputation: 6164Reputation: 6164Reputation: 6164Reputation: 6164Reputation: 6164Reputation: 6164Reputation: 6164
I tend to prefer wicd myself; it has never presented me with any issues.

It also has a nice ncurses interface that can be invoked from the terminal with the command wicd-curses.
 
Old 05-03-2020, 11:59 AM   #4
TBotNik
Member
 
Registered: May 2016
Location: Greenville, TX
Distribution: Kubuntu 18.04
Posts: 796

Original Poster
Rep: Reputation: Disabled
Followup

All,

I got both the wifi and the wired scripts working correctly, so this is solved.

TBNK
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sharing a wifi connection via a wifi router on a linux machine (see pic) linuxquestionsofandrew Linux - Networking 0 07-21-2013 06:45 AM
wifi connection issues with slackware 12.37 and broadcom wifi card EpicViTTo Slackware 15 09-05-2012 02:37 PM
[SOLVED] WiFi Connection Failure on Intel Corporation WiFi Link 5100 physicsguru Linux - Wireless Networking 1 04-08-2011 06:41 PM
dual wifi and wired connection: how to make a specific website use only wifi? shinji2001xyz Linux - Networking 2 04-08-2010 10:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook

All times are GMT -5. The time now is 09:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration