Every now and again, I need to start the Django development server, and have it viewable by other machines on my network, as described here:
http://docs.djangoproject.com/en/dev/ref/django-admin/#runserver
My machine’s IP address tends to change every now and again, so I’d like to have a little shell alias or something that spits out the manage.py command with my machine’s current IP address, maybe like this:
python manage.py runserver $(COMMAND TO FIND MY MACHINE’S IP ADDRESS GOES HERE):8000
The best solution would be to:
This may not be as elegant as some of the other solutions, but it works on Linux systems and is more comforting to look at than a regex:
Try this (if you are an Arch user)
Alternative
For getting IPv4 adress you can use:
For getting IPv6 one:
You can replace $(uname -n) with $(hostname) if you'd like.
Recap: if you'd like to
copy/paste
to command line and just get the network IP address, here's what works on Mac (on WiFi):Here is assigning it to bash script variable:
This is based on answers by Valentin Rocher and Matt Kropmton
The following command works perfectly for me on RHEL 6.3:
On Mac OS X 10.11.6 El Capitan (and probably older releases), you can print your IP with
where
<device>
isen0
,en1
, etc.http://osxdaily.com/2010/11/21/find-ip-address-mac/