LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 01-14-2007, 11:28 PM   #1
samvel
LQ Newbie
 
Registered: Dec 2006
Posts: 8

Rep: Reputation: 0
Exclamation Get Currently connected Network Name?


Configuration:
Laptop with KUbuntu 6.10 running on it.

Problem:
I have a laptop with SSHD running on it. The situation is that SSHD server is only used at home and should be turned off whenever I am connected to network at work/office (security restrictions out there). So, I need somehow to let my laptop start SSHD server only whenever I am at home and connected to home network of course administrated by myself.

Solution:
One possible solution of given problem is to put simple BASH script in /etc/init.d/start_ssh.sh that would start SSHD server or not depending on currently connected NETWORK name. The only problem here is how to get that NETWORK name in BASH (Python/C++/(T)CSH)? Any Ideas?



P.S. I have found some interesting folders in /etc/network/ with names:
if-down.d
if-post-down.d
if-pre-up.d
if-up.d
Maybe as a solution start_ssh.sh script should be put there which will be executed each time network is changed? What is their purpose?
 
Old 01-15-2007, 03:57 AM   #2
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,017

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Do you get a different address when you are at work?
ifconfig eth0 | grep inet will tell you your network address.
Then you could write some bash / sed / awk / python / whatever to decide whether to start sshd or not.
 
Old 01-15-2007, 08:18 AM   #3
samvel
LQ Newbie
 
Registered: Dec 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by tredegar
Do you get a different address when you are at work?
ifconfig eth0 | grep inet will tell you your network address.
Then you could write some bash / sed / awk / python / whatever to decide whether to start sshd or not.
Yes, I do get different IP address.
 
Old 01-15-2007, 02:24 PM   #4
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 231Reputation: 231Reputation: 231
It might be as easy as:
Code:
[ ifconfig eth0 | grep 'inet: addr:192' ] && sshd
or something similar. Where "192" is the shortest string that uniquely distinguishes your home LAN from work.
 
Old 01-17-2007, 11:00 AM   #5
samvel
LQ Newbie
 
Registered: Dec 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Lightbulb iwconfig

The solution is simple as usual. iwconfig will give me Access Point which is unique and can be used in order to get idea where am I working at: Home or Office.

The only problem is how to get the same information for wired connections? Sometimes I am using my cable network card. Any ideas?
 
  


Reply

Tags
bash, name


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Cannot install a network printer, that is connected directly to the network. Epeescott Linux - Networking 3 03-19-2006 08:31 PM
Connected to a different network and I want it to stop NeoChaosX Linux - Networking 3 02-22-2006 04:46 AM
On network but not connected to internet. tongueless Linux - Networking 3 01-25-2005 03:27 PM
connected to wireless network but no ip... pAn1k Linux - Wireless Networking 5 01-01-2005 04:09 PM
cannot see network when mac os x connected gSalsero Linux - Networking 1 06-21-2004 04:16 AM


All times are GMT -5. The time now is 09:30 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration