How to convert an IP address to binary. This is very easy with this command.

Posted: January 17, 2014. At: 2:54 PM. This was 4 years ago. Post ID: 6898

This simple one-liner allows conversion of an IP address from decimal to binary. I came up with this after playing around with cut and grep.

homer@deusexmachina ~/Documents $ ipcalc 172.18.31.2 | grep Address | cut -b 33-68
10101100.00010010.00011111. 00000010

The -b parameter to cut will only show certain bytes in the output of a command. useful if you do not want to use an extremely complex awk or sed one liner and you want to get just the data that you want.

Do you want to get the IP address of a host? Here is a useful way to do this.

homer@deusexmachina ~/Documents $ gethostip -d google.cn
74.125.31.160

This command will get the IP address of a local or remote host.

Another way to get information about a remote or local host is using the sipcalc command. This is easily installed on a Linux system and will allow you to get comprehensive information. Type yum install sipcalc on Fedora to install this useful command.

[homer@localhost ~]$ sipcalc -a 172.18.31.2/24
-[ipv4 : 172.18.31.2/24] - 0
 
[Classful]
Host address		- 172.18.31.2
Host address (decimal)	- 2886868738
Host address (hex)	- AC121F02
Network address		- 172.18.0.0
Network class		- B
Network mask		- 255.255.0.0
Network mask (hex)	- FFFF0000
Broadcast address	- 172.18.255.255
 
[CIDR]
Host address		- 172.18.31.2
Host address (decimal)	- 2886868738
Host address (hex)	- AC121F02
Network address		- 172.18.31.0
Network mask		- 255.255.255.0
Network mask (bits)	- 24
Network mask (hex)	- FFFFFF00
Broadcast address	- 172.18.31.255
Cisco wildcard		- 0.0.0.255
Addresses in network	- 256
Network range		- 172.18.31.0 - 172.18.31.255
Usable range		- 172.18.31.1 - 172.18.31.254
 
[Classful bitmaps]
Network address		- 10101100.00010010.00000000.00000000
Network mask		- 11111111.11111111.00000000.00000000
 
[CIDR bitmaps]
Host address		- 10101100.00010010.00011111.00000010
Network address		- 10101100.00010010.00011111.00000000
Network mask		- 11111111.11111111.11111111.00000000
Broadcast address	- 10101100.00010010.00011111.11111111
Cisco wildcard		- 00000000.00000000.00000000.11111111
Network range		- 10101100.00010010.00011111.00000000 -
			  10101100.00010010.00011111.11111111
Usable range		- 10101100.00010010.00011111.00000001 -
			  10101100.00010010.00011111.11111110
 
[Networks]
Network			- 172.18.31.0     - 172.18.31.255 (current)
 
-

The sipcalc command may also be used to show all IP addresses available on a network. This example shows how this works.

homer@deusexmachina ~/Documents $ sipcalc -a 172.18.31.2
-[ipv4 : 172.18.31.2] - 0
 
[Classfull]
Host address		- 172.18.31.2
Host address (decimal)	- 2886868738
Host address (hex)	- AC121F02
Network address		- 172.18.0.0
Network class		- B
Network mask		- 255.255.0.0
Network mask (hex)	- FFFF0000
Broadcast address	- 172.18.255.255
 
[CIDR]
Host address		- 172.18.31.2
Host address (decimal)	- 2886868738
Host address (hex)	- AC121F02
Network address		- 172.18.31.2
Network mask		- 255.255.255.255
Network mask (bits)	- 32
Network mask (hex)	- FFFFFFFF
Broadcast address	- 172.18.31.2
Cisco wildcard		- 0.0.0.0
Addresses in network	- 1
Network range		- 172.18.31.2 - 172.18.31.2
 
[Classfull bitmaps]
Network address		- 10101100.00010010.00000000.00000000
Network mask		- 11111111.11111111.00000000.00000000
 
[CIDR bitmaps]
Host address		- 10101100.00010010.00011111.00000010
Network address		- 10101100.00010010.00011111.00000010
Network mask		- 11111111.11111111.11111111.11111111
Broadcast address	- 10101100.00010010.00011111.00000010
Cisco wildcard		- 00000000.00000000.00000000.00000000
Network range		- 10101100.00010010.00011111.00000010 -
			  10101100.00010010.00011111.00000010
 
[Networks]
Network			- 172.18.31.0     - 172.18.31.0
Network			- 172.18.31.1     - 172.18.31.1
Network			- 172.18.31.2     - 172.18.31.2 (current)
Network			- 172.18.31.3     - 172.18.31.3
Network			- 172.18.31.4     - 172.18.31.4
Network			- 172.18.31.5     - 172.18.31.5
Network			- 172.18.31.6     - 172.18.31.6
Network			- 172.18.31.7     - 172.18.31.7
Network			- 172.18.31.8     - 172.18.31.8
Network			- 172.18.31.9     - 172.18.31.9
Network			- 172.18.31.10    - 172.18.31.10
Network			- 172.18.31.11    - 172.18.31.11
Network			- 172.18.31.12    - 172.18.31.12
Network			- 172.18.31.13    - 172.18.31.13
Network			- 172.18.31.14    - 172.18.31.14
Network			- 172.18.31.15    - 172.18.31.15
Network			- 172.18.31.16    - 172.18.31.16
Network			- 172.18.31.17    - 172.18.31.17
Network			- 172.18.31.18    - 172.18.31.18
Network			- 172.18.31.19    - 172.18.31.19
Network			- 172.18.31.20    - 172.18.31.20
Network			- 172.18.31.21    - 172.18.31.21
Network			- 172.18.31.22    - 172.18.31.22
Network			- 172.18.31.23    - 172.18.31.23
Network			- 172.18.31.24    - 172.18.31.24
Network			- 172.18.31.25    - 172.18.31.25
Network			- 172.18.31.26    - 172.18.31.26
Network			- 172.18.31.27    - 172.18.31.27
Network			- 172.18.31.28    - 172.18.31.28
Network			- 172.18.31.29    - 172.18.31.29
Network			- 172.18.31.30    - 172.18.31.30
Network			- 172.18.31.31    - 172.18.31.31
Network			- 172.18.31.32    - 172.18.31.32
Network			- 172.18.31.33    - 172.18.31.33
Network			- 172.18.31.34    - 172.18.31.34
Network			- 172.18.31.35    - 172.18.31.35
Network			- 172.18.31.36    - 172.18.31.36
Network			- 172.18.31.37    - 172.18.31.37
Network			- 172.18.31.38    - 172.18.31.38
Network			- 172.18.31.39    - 172.18.31.39
Network			- 172.18.31.40    - 172.18.31.40
Network			- 172.18.31.41    - 172.18.31.41
Network			- 172.18.31.42    - 172.18.31.42
Network			- 172.18.31.43    - 172.18.31.43
Network			- 172.18.31.44    - 172.18.31.44
Network			- 172.18.31.45    - 172.18.31.45
Network			- 172.18.31.46    - 172.18.31.46
Network			- 172.18.31.47    - 172.18.31.47
Network			- 172.18.31.48    - 172.18.31.48
Network			- 172.18.31.49    - 172.18.31.49
Network			- 172.18.31.50    - 172.18.31.50
Network			- 172.18.31.51    - 172.18.31.51
Network			- 172.18.31.52    - 172.18.31.52
Network			- 172.18.31.53    - 172.18.31.53
Network			- 172.18.31.54    - 172.18.31.54
Network			- 172.18.31.55    - 172.18.31.55
Network			- 172.18.31.56    - 172.18.31.56
Network			- 172.18.31.57    - 172.18.31.57
Network			- 172.18.31.58    - 172.18.31.58
Network			- 172.18.31.59    - 172.18.31.59
Network			- 172.18.31.60    - 172.18.31.60
Network			- 172.18.31.61    - 172.18.31.61
Network			- 172.18.31.62    - 172.18.31.62
Network			- 172.18.31.63    - 172.18.31.63
Network			- 172.18.31.64    - 172.18.31.64
Network			- 172.18.31.65    - 172.18.31.65
Network			- 172.18.31.66    - 172.18.31.66
Network			- 172.18.31.67    - 172.18.31.67
Network			- 172.18.31.68    - 172.18.31.68
Network			- 172.18.31.69    - 172.18.31.69
Network			- 172.18.31.70    - 172.18.31.70
Network			- 172.18.31.71    - 172.18.31.71
Network			- 172.18.31.72    - 172.18.31.72
Network			- 172.18.31.73    - 172.18.31.73
Network			- 172.18.31.74    - 172.18.31.74
Network			- 172.18.31.75    - 172.18.31.75
Network			- 172.18.31.76    - 172.18.31.76
Network			- 172.18.31.77    - 172.18.31.77
Network			- 172.18.31.78    - 172.18.31.78
Network			- 172.18.31.79    - 172.18.31.79
Network			- 172.18.31.80    - 172.18.31.80
Network			- 172.18.31.81    - 172.18.31.81
Network			- 172.18.31.82    - 172.18.31.82
Network			- 172.18.31.83    - 172.18.31.83
Network			- 172.18.31.84    - 172.18.31.84
Network			- 172.18.31.85    - 172.18.31.85
Network			- 172.18.31.86    - 172.18.31.86
Network			- 172.18.31.87    - 172.18.31.87
Network			- 172.18.31.88    - 172.18.31.88
Network			- 172.18.31.89    - 172.18.31.89
Network			- 172.18.31.90    - 172.18.31.90
Network			- 172.18.31.91    - 172.18.31.91
Network			- 172.18.31.92    - 172.18.31.92
Network			- 172.18.31.93    - 172.18.31.93
Network			- 172.18.31.94    - 172.18.31.94
Network			- 172.18.31.95    - 172.18.31.95
Network			- 172.18.31.96    - 172.18.31.96
Network			- 172.18.31.97    - 172.18.31.97
Network			- 172.18.31.98    - 172.18.31.98
Network			- 172.18.31.99    - 172.18.31.99
Network			- 172.18.31.100   - 172.18.31.100
Network			- 172.18.31.101   - 172.18.31.101
Network			- 172.18.31.102   - 172.18.31.102
Network			- 172.18.31.103   - 172.18.31.103
Network			- 172.18.31.104   - 172.18.31.104
Network			- 172.18.31.105   - 172.18.31.105
Network			- 172.18.31.106   - 172.18.31.106
Network			- 172.18.31.107   - 172.18.31.107
Network			- 172.18.31.108   - 172.18.31.108
Network			- 172.18.31.109   - 172.18.31.109
Network			- 172.18.31.110   - 172.18.31.110
Network			- 172.18.31.111   - 172.18.31.111
Network			- 172.18.31.112   - 172.18.31.112
Network			- 172.18.31.113   - 172.18.31.113
Network			- 172.18.31.114   - 172.18.31.114
Network			- 172.18.31.115   - 172.18.31.115
Network			- 172.18.31.116   - 172.18.31.116
Network			- 172.18.31.117   - 172.18.31.117
Network			- 172.18.31.118   - 172.18.31.118
Network			- 172.18.31.119   - 172.18.31.119
Network			- 172.18.31.120   - 172.18.31.120
Network			- 172.18.31.121   - 172.18.31.121
Network			- 172.18.31.122   - 172.18.31.122
Network			- 172.18.31.123   - 172.18.31.123
Network			- 172.18.31.124   - 172.18.31.124
Network			- 172.18.31.125   - 172.18.31.125
Network			- 172.18.31.126   - 172.18.31.126
Network			- 172.18.31.127   - 172.18.31.127
Network			- 172.18.31.128   - 172.18.31.128
Network			- 172.18.31.129   - 172.18.31.129
Network			- 172.18.31.130   - 172.18.31.130
Network			- 172.18.31.131   - 172.18.31.131
Network			- 172.18.31.132   - 172.18.31.132
Network			- 172.18.31.133   - 172.18.31.133
Network			- 172.18.31.134   - 172.18.31.134
Network			- 172.18.31.135   - 172.18.31.135
Network			- 172.18.31.136   - 172.18.31.136
Network			- 172.18.31.137   - 172.18.31.137
Network			- 172.18.31.138   - 172.18.31.138
Network			- 172.18.31.139   - 172.18.31.139
Network			- 172.18.31.140   - 172.18.31.140
Network			- 172.18.31.141   - 172.18.31.141
Network			- 172.18.31.142   - 172.18.31.142
Network			- 172.18.31.143   - 172.18.31.143
Network			- 172.18.31.144   - 172.18.31.144
Network			- 172.18.31.145   - 172.18.31.145
Network			- 172.18.31.146   - 172.18.31.146
Network			- 172.18.31.147   - 172.18.31.147
Network			- 172.18.31.148   - 172.18.31.148
Network			- 172.18.31.149   - 172.18.31.149
Network			- 172.18.31.150   - 172.18.31.150
Network			- 172.18.31.151   - 172.18.31.151
Network			- 172.18.31.152   - 172.18.31.152
Network			- 172.18.31.153   - 172.18.31.153
Network			- 172.18.31.154   - 172.18.31.154
Network			- 172.18.31.155   - 172.18.31.155
Network			- 172.18.31.156   - 172.18.31.156
Network			- 172.18.31.157   - 172.18.31.157
Network			- 172.18.31.158   - 172.18.31.158
Network			- 172.18.31.159   - 172.18.31.159
Network			- 172.18.31.160   - 172.18.31.160
Network			- 172.18.31.161   - 172.18.31.161
Network			- 172.18.31.162   - 172.18.31.162
Network			- 172.18.31.163   - 172.18.31.163
Network			- 172.18.31.164   - 172.18.31.164
Network			- 172.18.31.165   - 172.18.31.165
Network			- 172.18.31.166   - 172.18.31.166
Network			- 172.18.31.167   - 172.18.31.167
Network			- 172.18.31.168   - 172.18.31.168
Network			- 172.18.31.169   - 172.18.31.169
Network			- 172.18.31.170   - 172.18.31.170
Network			- 172.18.31.171   - 172.18.31.171
Network			- 172.18.31.172   - 172.18.31.172
Network			- 172.18.31.173   - 172.18.31.173
Network			- 172.18.31.174   - 172.18.31.174
Network			- 172.18.31.175   - 172.18.31.175
Network			- 172.18.31.176   - 172.18.31.176
Network			- 172.18.31.177   - 172.18.31.177
Network			- 172.18.31.178   - 172.18.31.178
Network			- 172.18.31.179   - 172.18.31.179
Network			- 172.18.31.180   - 172.18.31.180
Network			- 172.18.31.181   - 172.18.31.181
Network			- 172.18.31.182   - 172.18.31.182
Network			- 172.18.31.183   - 172.18.31.183
Network			- 172.18.31.184   - 172.18.31.184
Network			- 172.18.31.185   - 172.18.31.185
Network			- 172.18.31.186   - 172.18.31.186
Network			- 172.18.31.187   - 172.18.31.187
Network			- 172.18.31.188   - 172.18.31.188
Network			- 172.18.31.189   - 172.18.31.189
Network			- 172.18.31.190   - 172.18.31.190
Network			- 172.18.31.191   - 172.18.31.191
Network			- 172.18.31.192   - 172.18.31.192
Network			- 172.18.31.193   - 172.18.31.193
Network			- 172.18.31.194   - 172.18.31.194
Network			- 172.18.31.195   - 172.18.31.195
Network			- 172.18.31.196   - 172.18.31.196
Network			- 172.18.31.197   - 172.18.31.197
Network			- 172.18.31.198   - 172.18.31.198
Network			- 172.18.31.199   - 172.18.31.199
Network			- 172.18.31.200   - 172.18.31.200
Network			- 172.18.31.201   - 172.18.31.201
Network			- 172.18.31.202   - 172.18.31.202
Network			- 172.18.31.203   - 172.18.31.203
Network			- 172.18.31.204   - 172.18.31.204
Network			- 172.18.31.205   - 172.18.31.205
Network			- 172.18.31.206   - 172.18.31.206
Network			- 172.18.31.207   - 172.18.31.207
Network			- 172.18.31.208   - 172.18.31.208
Network			- 172.18.31.209   - 172.18.31.209
Network			- 172.18.31.210   - 172.18.31.210
Network			- 172.18.31.211   - 172.18.31.211
Network			- 172.18.31.212   - 172.18.31.212
Network			- 172.18.31.213   - 172.18.31.213
Network			- 172.18.31.214   - 172.18.31.214
Network			- 172.18.31.215   - 172.18.31.215
Network			- 172.18.31.216   - 172.18.31.216
Network			- 172.18.31.217   - 172.18.31.217
Network			- 172.18.31.218   - 172.18.31.218
Network			- 172.18.31.219   - 172.18.31.219
Network			- 172.18.31.220   - 172.18.31.220
Network			- 172.18.31.221   - 172.18.31.221
Network			- 172.18.31.222   - 172.18.31.222
Network			- 172.18.31.223   - 172.18.31.223
Network			- 172.18.31.224   - 172.18.31.224
Network			- 172.18.31.225   - 172.18.31.225
Network			- 172.18.31.226   - 172.18.31.226
Network			- 172.18.31.227   - 172.18.31.227
Network			- 172.18.31.228   - 172.18.31.228
Network			- 172.18.31.229   - 172.18.31.229
Network			- 172.18.31.230   - 172.18.31.230
Network			- 172.18.31.231   - 172.18.31.231
Network			- 172.18.31.232   - 172.18.31.232
Network			- 172.18.31.233   - 172.18.31.233
Network			- 172.18.31.234   - 172.18.31.234
Network			- 172.18.31.235   - 172.18.31.235
Network			- 172.18.31.236   - 172.18.31.236
Network			- 172.18.31.237   - 172.18.31.237
Network			- 172.18.31.238   - 172.18.31.238
Network			- 172.18.31.239   - 172.18.31.239
Network			- 172.18.31.240   - 172.18.31.240
Network			- 172.18.31.241   - 172.18.31.241
Network			- 172.18.31.242   - 172.18.31.242
Network			- 172.18.31.243   - 172.18.31.243
Network			- 172.18.31.244   - 172.18.31.244
Network			- 172.18.31.245   - 172.18.31.245
Network			- 172.18.31.246   - 172.18.31.246
Network			- 172.18.31.247   - 172.18.31.247
Network			- 172.18.31.248   - 172.18.31.248
Network			- 172.18.31.249   - 172.18.31.249
Network			- 172.18.31.250   - 172.18.31.250
Network			- 172.18.31.251   - 172.18.31.251
Network			- 172.18.31.252   - 172.18.31.252
Network			- 172.18.31.253   - 172.18.31.253
Network			- 172.18.31.254   - 172.18.31.254
Network			- 172.18.31.255   - 172.18.31.255
 
-

No comments have been made. Use this form to start the conversation :)

Leave a Reply