Tag Archives: ip

How to Find Server Public IP Address in Linux Terminal

root@test:/var/log/nginx# wget -qO – icanhazip.com
www.xxx.yyy.zzz
root@test:/var/log/nginx# wget -qO- http://ipecho.net/plain | xargs echo
www.xxx.yyy.zzz
root@test:/var/log/nginx# wget -qO – icanhazip.com
www.xxx.yyy.zzz
root@test:/var/log/nginx# curl icanhazip.com
www.xxx.yyy.zzz
root@test:/var/log/nginx#

Microsoft Azure Set a Static Internal IP Address for a VM

Before you specify a static IP address from your address pool, you may want to verify that the IP address has not been already assigned. In the example below, we’re checking to see whether the IP address 10.1.61.140 is available in the TestVNet virtual network.

Test-AzureStaticVNetIP –VNetName TestVNet –IPAddress 10.1.61.140 

Be sure to change the variables for the cmdlets to reflect what you require for your environment before running them.

New-AzureVMConfig -Name $vmname -ImageName $img –InstanceSize Small | Set-AzureSubnet –SubnetNames $sub | Set-AzureStaticVNetIP -IPAddress 10.1.61.140 | New-AzureVM –ServiceName $vmsvc1 –VNetName TestVNet

If you want to set a static IP address for a VM that you previously created, you can do so by using the following cmdlets. If you already set an IP address for the VM and you want to change it to a different IP address, you’ll need to remove the existing static IP address before running these cmdlets. See the instructions below to remove a static IP.

For this procedure, you’ll use the Update-AzureVM cmdlet. The Update-AzureVM cmdlet restarts the VM as part of the update process. The DIP that you specify will be assigned after the VM restarts. In this example, we set the IP address for VM2, which is located in cloud service StaticDemo.

Get-AzureVM -ServiceName StaticDemo -Name VM2 | Set-AzureStaticVNetIP -IPAddress 10.1.61.140 | Update-AzureVM

When you remove a static IP address from a VM, the VM will automatically receive a new DIP after the VM restarts as part of the update process. In the example below, we remove the static IP from VM2, which is located in cloud service StaticDemo.

Get-AzureVM -ServiceName StaticDemo -Name VM2 | Remove-AzureStaticVNetIP | Update-AzureVM

Unix Sort by IP Address

[root@sunx4150 ~]# cat /etc/hosts

# Do not remove the following line, or various programs
# that require network functionality will fail.
10.1.50.101             sunx4150.xyz.com localhost.localdomain localhost
127.0.0.1               sunx4150.xyz.com localhost.localdomain localhost
10.0.51.50      T5220   T5220.xyz.com
10.0.50.36      ibmaix  ibmaix.xyz.com
10.0.50.9            bucnodc01.xyz.com
10.0.50.36      ibmaix.xyz.com ibmaix
10.1.50.106    ibmcl03.xyz.com     ibmcl03
10.1.51.83      nnl106.xyz.com
10.1.50.134     dbcimb01
10.0.2.20        bkonetapp1
10.112.2.101     spblrdc010
10.0.2.11        bpelapp1
[root@sunx4150 ~]#
[root@sunx4150 ~]#

[root@sunx4150 ~]# sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n /etc/hosts

# Do not remove the following line, or various programs
# that require network functionality will fail.
10.0.2.11        bpelapp1
10.0.2.20        bkonetapp1
10.0.50.9         bucnodc01.xyz.com
10.0.50.36      ibmaix  ibmaix.xyz.com
10.0.50.36      ibmaix.xyz.com ibmaix
10.0.51.50      T5220   T5220.xyz.com
10.1.50.101             sunx4150.xyz.com localhost.localdomain localhost
10.1.50.106    ibmcl03.xyz.com     ibmcl03
10.1.50.134     dbcimb01
10.1.51.83      nnl106.xyz.com
10.112.2.101     spblrdc010
127.0.0.1               sunx4150.xyz.com localhost.localdomain localhost
[root@sunx4150 ~]#
[root@sunx4150 ~]#

[root@sunx4150 ~]# sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n /etc/hosts | awk '$1!~/:/ &&

!/^$/ && !/^#/’
10.0.2.11        bpelapp1
10.0.2.20        bkonetapp1
10.0.50.9        bucnodc01.xyz.com
10.0.50.36      ibmaix  ibmaix.xyz.com
10.0.50.36      ibmaix.xyz.com ibmaix
10.0.51.50      T5220   T5220.xyz.com
10.1.50.101             sunx4150.xyz.com localhost.localdomain localhost
10.1.50.106    ibmcl03.xyz.com     ibmcl03
10.1.50.134     dbcimb01
10.1.51.83      nnl106.xyz.com
10.112.2.101     spblrdc010
127.0.0.1               sunx4150.xyz.com localhost.localdomain localhost

[root@sunx4150 ~]# sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n /etc/hosts | awk '$1!~/:/ && !/^$/ && !/^#/ && !/localhost/'

10.0.2.11        bpelapp1
10.0.2.20        bkonetapp1
10.0.50.9        bucnodc01.xyz.com
10.0.50.36      ibmaix  ibmaix.xyz.com
10.0.50.36      ibmaix.xyz.com ibmaix
10.0.51.50      T5220   T5220.xyz.com
10.1.50.106    ibmcl03.xyz.com     ibmcl03
10.1.50.134     dbcimb01
10.1.51.83      nnl106.xyz.com
10.112.2.101     spblrdc010
[root@sunx4150 ~]#