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:
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).
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
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
hostname
, ifconfig
, 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
Post a Comment