LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 12-16-2014, 11:38 AM   #1
marchelloUA
LQ Newbie
 
Registered: Nov 2014
Posts: 27

Rep: Reputation: Disabled
Question run script when wwan0 interface obtains IP address


Hi all,

My need is to run script when wwan0 interface obtains IP address.
How do I perform it?
Thanks ahead.

Ubuntu 14.04.1 LTS
 
Old 12-16-2014, 02:40 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
I gotta be honest with you, I had this same conundrum a few years ago and I solved it with brute force which was to have another script or program run for a long, but finite period of time, say 2 minutes and poll the interface status, and by observing the status, I'd be able to detect if an address was negotiated versus not. Then following that I gave status back to my GUI, but similarly I could've then invoked a script. I did nothing more than parsed the output of ifconfig for that interface to determine if a valid address was set for that interface. Say maybe did that once every 5 seconds for a count of 24 iterations before I gave up.
 
Old 12-17-2014, 05:04 AM   #3
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750
If you use NetworkManager, then perhaps you could use a script in /etc/NetworkManager/dispatcher.d/ that checks the interface name and the appropriate dhcp change action (either v4 or v6) to signal whether further commands should be run. See 'man NetwrkManager' for details.
As an example, here is the script I use to change firewall rules depending on the interface in use on my netbook. http://www.linuxquestions.org/questi...1/#post4579765
 
Old 12-17-2014, 05:41 AM   #4
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
To know the ip address of all network interfaces in your system just run:

ip a

And use shell grep awk to parse it.
 
  


Reply

Tags
script



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
Run script on new lease only for certain interface jluce50 Linux - Networking 2 09-17-2014 11:53 AM
run auto script when interface comes up or down on centos bobo0110 Linux - Server 1 03-15-2011 04:31 AM
run auto script when interface comes up or down on centos bobo0110 Linux - Newbie 2 03-15-2011 02:15 AM
Reconfiguring an interface to run in promiscuous mode with no ip address kaplan71 Fedora 1 10-13-2004 02:05 PM
how to run script on event ppp0 interface going down ? qwijibow Linux - Networking 4 02-24-2004 06:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:27 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