Skip to main content

Virtual IP Address (VIPA) & Determine Your Private and Public IP Addresses from the Command Line

A virtual IP address (VIPA) is an IP address assigned to multiple domain names or servers that share an IP address based on a single network interface card (NIC). VIPAs are allocated to virtual private servers, websites or any other application residing on a single server. The host server for these applications has a network IP address assigned by a network administrator, whereas the different server applications have VIPAs. VIPAs enhance network load balancing and redundancy.

VIPAs are primarily implemented for the following reasons:
  • To consolidate resources through the allocation of one network interface per hosted application
  • To improve redundancy by providing alternative failover options on one machine

A server IP address depends on the Media Access Control (MAC) address of the attached NIC, and only one logical IP address may be assigned per card. However, VIP addressing enables hosting for several different applications and virtual appliances on a server with only one logical IP address. The VIPA is used for communication by all hosted applications - even though data packets are routed through actual network interfaces. 

Several different application instances may be hosted with different VIPAs on the same server and easily switched for improved load balancing/performance and reduced latency. 

VIPAs have several variations and implementation scenarios, including Common Address Redundancy Protocol (CARP) and Proxy Address Resolution Protocol (Proxy ARP).


Determine Your Private and Public IP Addresses from the Command Line


Displaying private IP addresses

You can determine the IP address or addresses of your Linux system by using the hostnameifconfig, or ip commands. To display the IP addresses using the hostname command, use the -I option. In this example the IP address is 192.168.122.236.
$ hostname -I
192.168.122.236 
The ifconfig command can also be used to display the IP addresses being used by the system. By default ifconfig will display information on all the network interfaces that are currently up, including the loopback interface.
$ /sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:43:84:6c  
          inet addr:192.168.122.236  Bcast:192.168.122.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe43:846c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:304863 errors:0 dropped:0 overruns:0 frame:0
          TX packets:129646 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:53349734 (53.3 MB)  TX bytes:130802964 (130.8 MB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:2059079 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2059079 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:383294965 (383.2 MB)  TX bytes:383294965 (383.2 MB)
To gather information on just one interface, supply that interface as an argument to ifconfig. You can even take this a step further and extract the line that contains the IP address or even extract the IP address itself.
$ /sbin/ifconfig eth0 | grep Mask
          inet addr:192.168.122.236  Bcast:192.168.122.255  Mask:255.255.255.0
$ /sbin/ifconfig eth0 | grep Mask | awk '{print $2}'| cut -f2 -d:
192.168.122.236
Let’s do the same thing with the ip command. To view ip addresses, use ip addr show. Like ifconfig, you can specify an interface.
$ ip addr show
1: lo:  mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:43:84:6c brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.236/24 brd 192.168.122.255 scope global eth0
    inet6 fe80::5054:ff:fe43:846c/64 scope link 
       valid_lft forever preferred_lft forever
$ ip addr show eth0
2: eth0:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:43:84:6c brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.236/24 brd 192.168.122.255 scope global eth0
    inet6 fe80::5054:ff:fe43:846c/64 scope link 
       valid_lft forever preferred_lft forever
$ ip addr show eth0 | grep 'inet ' | awk '{print $2}' | cut -f1 -d'/'
192.168.122.236

Displaying the public IP address

If you want to know the public IP address of a Linux server, you can send an HTTP request to one of the following web servers.
  • http://ifconfig.me
  • http://www.icanhazip.com
  • http://ipecho.net/plain
  • http://indent.me
  • http://bot.whatismyipaddress.com
  • https://diagnostic.opendns.com/myip
  • http://checkip.amazonaws.com
If the Linux system is connected directly to the internet, the public and private IP addresses will be the same. However, in most cases they differ. Here is an example using the curl command.
$ curl ifconfig.me
216.239.32.10
$ curl icanhazip.com
216.239.32.10
$ curl ipecho.net/plain
216.239.32.10
$ curl ident.me
216.239.32.10
$ curl bot.whatismyipaddress.com
216.239.32.10
$ curl https://diagnostic.opendns.com/myip
216.239.32.10
$ curl http://checkip.amazonaws.com
216.239.32.10
You can also achieve the same result with wget by enabling quiet mode with -q and sending the output to standard output (STDOUT) with -O-.
$ wget -qO- ifconfig.me
216.239.32.10
There’s yet another way to determine your public IP address. Perform a DNS lookup against myip.opendns.com. It’s a service provided by OpenDNS and it’s lightening fast!
$ dig +short myip.opendns.com @resolver1.opendns.com
216.239.32.10

Comments

Popular posts from this blog

Boot process hangs at dracut: Switching root

Environment Red Hat Enterprise Linux 6 Issue When server is booting the boot process hangs at  dracut: Switching root , and never displays anything else. Raw device-mapper: ioctl: 4.33.1-ioctl (2015-8-18) initialised: xx-xxxx@redhat.com udev: starting version 147 dracut: Starting plymouth daemon dracut: rd_NO_DM: removing DM RAID activation dracut: rd_NO_MD: removing MD RAID activation scsi0 : ata_piix scsi1 : ata_piix ata1: PATA max MWDMA2 cmd 0x1f0 ctl 0x3f6 bmdma 0xc120 irq 14 ata2: PATA max MWDMA2 cmd 0x170 ctl 0x376 bmdma 0xc128 irq 15 Refined TSC clocksource calibration: 2599.999 MHz. virtio-pci 0000:00:03.0: PCI INT A -> Link[LNKC] -> GSI 11 (level, high) -> IRQ 11 virtio-pci 0000:00:05.0: PCI INT A -> Link[LNKA] -> GSI 10 (level, high) -> IRQ 10 virtio-pci 0000:00:07.0: PCI INT A -> Link[LNKC] -> GSI 11 (level, high) -> IRQ 11 virtio-pci 0000:00:08.0: PCI INT A -> Link[LNKD] -> GSI 11 (level, high) -> IRQ 11 input: ImExPS/2 Gener

Interpreting the output of lspci

On Linux, the lspci command lists all PCI devices connected to a host (a computer). Modern computers and PCI devices communicate with each other via PCI Express buses instead of the older Conventional PCI and PCI-X buses since the former buses offer many advantages such as higher throughput rates, smaller physical footprint and native hot plugging functionality. The high performance of the PCI Express bus has also led it to take over the role of other buses such as AGP ; it is also expected that SATA buses too will be replaced by PCI Express buses in the future as solid-state drives become faster and therefore demand higher throughputs from the bus they are attached to (see this article for more on this topic). As a first step, open a terminal and run lspci without any flags (note: lspci may show more information if executed with root privileges): lspci   This is the output I get on my laptop: 00:00.0 Host bridge: Intel Corporation Haswell-ULT DRAM Co

How to get the SAN environment information and statistics on AIX, HP-UX, Linux, Solaris, and Windows

How to get the SAN environment information and statistics on AIX, HP-UX, Linux, Solaris, and Windows Description NetBackup SAN Client is supported on the Linux , Solaris, Windows, HP-UX and AIX operating systems.  These environments provide the initiator device driver which can login to the SAN client media server and mount an pseudo   target device “ARCHIVE PYTHON” so that the backup or restore can be use the fiber transport (FT).  If there is an issue in the SAN environment, it is necessary to get the information/statistics from the SAN fabric for analysis.  The commands below can be used, on the respective operating system, to gather the necessary information. If the outputs show many or steadily increasing error counts, that indicates one or more issues with  the fabric  infrastructure. The issue(s) can be caused by cabling, SFP, san switch, DWDM, HBA or ISL and those components will need to be analyzed and evaluated.  Linux Get the hardware information fo