Total IP to CIDR Conversion - ip

I know Start IP Address aka Network Id and also total IP Address as well but how I can calculate its CIDR or End IP from it without knowing Subnet Mask.
Example
Start IP : 192.168.8.0
Total IP : 1024

1024 IP addresses is a /22 CIDR and the network mask would be 255.255.252.0
You can go to http://ipconvertertools.com/cidr2ipranges and convert 192.168.8.0/22 to IP range.
You will get:
Network Address First IP Last IP Subnet Mask Broadcast Total IP's
192.168.8.0 192.168.8.1 192.168.11.254 255.255.252.0 192.168.11.255 1021
Just add few IP's so you will have 1024 total IP
How to convert manually:
Convert IP to binary -> 11000000101010000000100000000000
Convert total IP -> 10000000000
======
11000000101010000000100000000000 +
10000000000 =
----------------------------------
11000000101010000000110000000000 = 192.168.12.0
(where is 0 remains zero. If in the same column there is 1, it becomes 1)

Related

Terminal not seeing ping messages from TUN port

Hi I'm working on a project and I had a question involving ping commands and how they interface over network TUN ports.
Basically I'm sending out ping requests which are routed to my TUN port and the reply's are sent to the TUN port over the VPN. There are no other internet interfaces (i.e. no wifi/ethernet). Using wireshark and tcpdump I can see that the correct reply messages are seen on the TUN0 port but terminal does not see the replys and instead shows 100% drop rate. The issue seems to be that the TUN0 port is not properly linking back to the kernal? (total guess I'm quite new to IP routing).
The IP address of the TUN is 10.0.0.73 and I am pinging a computer with IP address 10.0.0.28
Bellow is a snippet from the tcpdump on TUN0 this is a request and reply that to my untrained eye should work:
23:08:52.257566 IP (tos 0x0, ttl 64, id 11185, offset 0, flags [DF], proto ICMP (1), length 84)
10.0.0.73 > 10.0.0.28: ICMP echo request, id 24667, seq 2, length 64
23:09:11.508002 IP (tos 0x0, ttl 64, id 13315, offset 0, flags [none], proto ICMP (1), length 84)
10.0.0.28 > 10.0.0.73: ICMP echo reply, id 24667, seq 2, length 64
Based on other posts I checked my ip route list and the output is as such
pi#raspberrypi:~$ sudo ip route list
10.0.0.0/24 dev tun0 proto kernel scope link src 10.0.0.73
and the ifconfig is this:
pi#raspberrypi:~$ ifconfig tun0
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.0.0.73 P-t-P 10.0.0.73 Mask:255.255.255.0
...
Turns out the issue was that the replies were showing up in incorrect orders and greatly delayed, when I fixed the network connections this issue went away without changing any configurations in the iptables

How to tell which IP is valid only based on the given subnet mask

I'm looking for a way to tell which IP is valid only based on the given subnet mask.
For example : given the subnet mask : 255.255.255.240, is 195.206.108.25 a valid IP? Why?
IP: 195.206.108.25
MASK: 255.255.255.240 (/28)
255.255.255.255
- 255.255.255.240
---------------------
0. 0. 0. 15
Network: 195.206.108.0/28
Usable hosts: 195.206.108.1-195.206.108.14
Broadcast: 195.206.108.15
Network: 195.206.108.16/28
Usable hosts: 195.206.108.17-195.206.108.30
Broadcast: 195.206.108.31
So 195.206.108.25 is a valid IP address of the 195.206.108.16/28 network. (correct me if I'm wrong)

Access Host between two Subnetworks

Can this two hosts ping/access each other without routing?
Host A:
172.17.1.1
255.255.255.0
N-ID: 172.17.1.0
BC: 172.17.1.255
Host B:
172.17.1.10
255.255.0.0
N-ID: 172.17.0.0
BC: 172.17.255.255
Yes, both machines think they are on same network, as the subnet mask includes both addresses on both hosts.

How can i calculate ip address range from subnet mask

When I use this command which IP addresed are scanned
# nmap -sP 192.168.0.120/25
How can I get the IP range when I have the addres and subnet. Because I am trying to understand this, but no result till now..Please help me..Thank a lot
You can use ipcalc, a nice *nix tool to guide you:
~ $ ipcalc 192.168.0.120/25
Address: 192.168.0.120 11000000.10101000.00000000.0 1111000
Netmask: 255.255.255.128 = 25 11111111.11111111.11111111.1 0000000
Wildcard: 0.0.0.127 00000000.00000000.00000000.0 1111111
=>
Network: 192.168.0.0/25 11000000.10101000.00000000.0 0000000
HostMin: 192.168.0.1 11000000.10101000.00000000.0 0000001
HostMax: 192.168.0.126 11000000.10101000.00000000.0 1111110
Broadcast: 192.168.0.127 11000000.10101000.00000000.0 1111111
Hosts/Net: 126 Class C, Private Internet
192.168.0.120
This says that the IP address is 192.168.0.120.
/25
This says that the netmask is 25 bits long. As an IPv4 address is 32 bits, that leaves 7 bits for the address. The lowest IP address in the range is given by masking out the bottom 7 bits, and the highest by adding 127 (=27-1) to that.

Creating subnets

Using the following IP Range can anyone break this down into 3 subnets for me displaying IP's in each range and their subnet masks please
Current setting below needs breaking into 3 the start off the range needs to be the smallest subnet.
IP Range 192.168.1.128 - 192.168.1.159
Gateway 192.168.1.129
Subnet 255.255.255.224
Usable 192.168.1.132 - 192.168.1.158
Many thanks
Using the SubNetMask 255.255.255.248 you should quarter the IP-Range. So the new nets are:
1) IP: 192.168.1.128
Usable: 192.168.1.129 - 192.168.1.134 (.135 is Broadcast)
2) IP: 192.168.1.136
Usable: 192.168.1.137 - 192.168.1.142 (.143 is Broadcast)
3) IP: 192.168.1.144
Usable: 192.168.1.145 - 192.168.1.150 (.151 is Broadcast)
4) IP: 192.168.1.152
Usable: 192.168.1.153 - 192.168.1.158 (.159 is Broadcast)

Resources