Showing posts with label ifconfig. Show all posts
Showing posts with label ifconfig. Show all posts

09 May, 2015

Wan IP, external service WAN

Finding external IP using external services

The easiest way is to use an external service via a commandline browser or download tool. Since wget is available by default in Ubuntu, we can use that.
To find your ip, use-

 
wget -qO- http://ipecho.net/plain ; echo

You could also use lynx(browser) or curl in place of wget with minor variations to the above command, to find your external ip.
Using curl to find the ip:
 
curl ipecho.net/plain

For a better formatted output use:
 
curl ipecho.net/plain ; echo

A faster(arguably the fastest)
method using dig with OpenDNS as resolver:

The other answers here all go over HTTP to a remote server. Some of them require parsing of the output, or rely on the User-Agent header to make the server respond in plain text. They also change quite frequently (go down, change their name, put up ads, might change output format etc.).

  1. The DNS response protocol is standardised (the format will stay compatible).
  2. Historically DNS services (OpenDNS, Google Public DNS, ..) tend to survive much longer and are more stable, scalable and generally looked after than whatever new hip whatismyip.com HTTP service is hot today.
  3. (for those geeks that care about micro-optimisation), this method should be inherently faster (be it only by a few micro seconds).
Using dig with OpenDNS as resolver:
$ dig +short myip.opendns.com @resolver1.opendns.com
111.222.333.444
 


Finding external IP
without relying on external services

  • If you know your network interface name
Type the following in your terminal:
 
ifconfig  | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'

In the above, replace with the name of your actual interface, e.g:  

eth0, eth1, pp0, etc...

Example Usage:
 
mycomp@geek:~$ ifconfig ppp0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'
111.222.333.444
  • If you don't know your network interface name
Type the following in your terminal (this gets the ip address of every network interface in your system):
 
ifconfig |grep -B1 "inet addr" |awk '{ if ( $1 == "inet" ) { print $2 } 
else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' |awk -F: '{ print $1 ": " $3 }'

Example Usage:
 
mycomp@geek:~$ ifconfig |grep -B1 "inet addr" |awk '{ if ( $1 == "inet" ) { print $2 } 
else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' |awk -F: '{ print $1 ": " $3 }'
lo: 127.0.0.1
ppp0: 111.222.333.444

12 March, 2013

Manually assign (add) fixed (static) IP on FreeBSD


Manually assign/add fixed/static IP on FreeBSD:
 
ifconfig em0 inet  netmask 
route add default 
/etc/netstart

e.g.

ifconfig em0 inet 192.168.0.10 netmask 255.255.255.0
route add default 192.168.0.1
/etc/netstart

Make changes permanently :
As an example of the above, insert the below parameters into /etc/rc.conf :

ifconfig_em0="inet 192.168.0.10 netmask 255.255.255.0"
defaultrouter="192.168.0.1"
hostname="hostname.domain.com"

Remove assigned IP address from network interface

ifconfig  down delete
e.g.

ifconfig em0 down delete

15 January, 2013

...connect to a Wireless Network from Terminal...

How do I connect to a Wireless Network from Terminal-only?


View available wireless networks:
Code:
iwlist  scan
(Replacing with your wireless interface [for example mine is eth2)
If you don't get any networks listed:

Code:
ifconfig  up
To turn on your wireless interface.
If your wireless network is WPA encrypted:

Code:
iwconfig  essid  key s:
(Note: I use "s:" so that I can enter my key in ASCII form e.g. "Kll4Wx"
If your network isn't secured:

Code:
iwconfig  essid 
I hope this helps, if you want more help just let me know!

25 March, 2008

DNS cache > How to Flush DNS in Different OS’es?



There is some ways you can make DNSFLUSH on several operating systems, and here you will se some of that
examples.
Most DNS clients cache the results of name resolution requests. This speeds up name resolution if multiple lookups are done to the same address, such as is common when browsing the web. Sometimes a bad
DNS entry will be cached and you will need to either flush the DNS cache to get rid of it, or wait up to 24 hours for it to be dropped from the cache automatically.


  • How to Flush DNS in Linux
  • In Linux, the nscd daemon manages the DNS cache. To flush the DNS cache, restart the nscd daemon.
    To restart the nscd daemon, use the command

    #$: /etc/rc.d/init.d/nscd restart


  • How to Flush DNS in Mac OSX
  • In Mac OSX, you can use the command lookupd -flushcache to flush the DNS resolver cache.
    bash-2.05a$ lookupd -flushcache



  • How to Flush DNS in Microsoft Windows
  • In Microsoft Windows, you can use the command

    C:> ipconfig /flushdns to flush the DNS resolver cache.

    Windows IP Configuration Successfully flushed the DNS Resolver Cache.


    You can also use the command

    C:> ipconfig /displaydns to view the DNS resolver cache.



cache, dns, Linux, MacOSX, Windows