Creating subnets - ip

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)

Related

How to remove "IPv4 address parameter" field (optional) in a SCTP packet in Ubuntu

I want to send a SCTP packet to a server using L2TP VPN in Ubuntu 20.04. For this purpose, I have set up my L2TP VPN and I can successfully test the connection using ping command. Now my ifconfig output is as follows:
enp0s31f6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet x.x.x.x netmask 255.255.255.248 broadcast p.p.p.p
...
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
...
ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1400
inet y.y.y.y netmask 255.255.255.255 destination q.q.q.q
...
In this output, x.x.x.x is my LAN IP and y.y.y.y is my VPN IP.
But when I send my INIT SCTP packet, two optional fields, i.e. IPv4 address parameter, is appeared in INIT chunk subtree in Wireshark log as follows. These parameters contain my IPs.
Stream Control Transmission Protocol, Src Port: a (a), Dst Port: b (b)
Source port: a
Destination port: b
Verification tag: 0x00000000
[Association index: 65535]
Checksum: 0x06cf8029 [unverified]
[Checksum Status: Unverified]
INIT chunk (Outbound streams: 3, inbound streams: 3)
Chunk type: INIT (1)
0... .... = Bit: Stop processing of the packet
.0.. .... = Bit: Do not report
Chunk flags: 0x00
Chunk length: 52
Initiate tag: 0xd1d6f19b
Advertised receiver window credit (a_rwnd): 106496
Number of outbound streams: 3
Number of inbound streams: 3
Initial TSN: 1216798565
IPv4 address parameter (Address: x.x.x.x)
IPv4 address parameter (Address: y.y.y.y)
Supported address types parameter (Supported types: IPv4)
ECN parameter
Forward TSN supported parameter
and finally, here is the sent and received packets:
I think that IPv4 address parameter (Address: x.x.x.x) (my LAN IP) in my INIT packet, has caused to receive the ABORT packet from server. When I turn off my VPN, these two optional fields do not appear.
How can I remove these two optional fields in Ubuntu after turning up my VPN?
Manual client IP assignment is required to remove "IPv4 address parameter" fields in a SCTP packet. So, the following codes is required in C++:
int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
if(sock < 0)
{
//handle error
}
struct sockaddr_in clientAddr;
memset(&clientAddr,0, sizeof(struct sockaddr_in));
clientAddr.sin_family = AF_INET;
clientAddr.sin_addr.s_addr = inet_addr("y.y.y.y");
clientAddr.sin_port = htons(a);
if( ::bind(sock, (struct sockaddr*)&clientAddr, sizeof(struct sockaddr)) < 0 )
{
//handle error
}

Can't access cross VM of different zones

I have 2 VM instances using the same network(default), same subnet (default), but in 2 different zones. I accessed the VM and then ping to another VM but they did not resolve! What do I have to do to make them communicate? Below is the information of the system:
Network:
- Name: default
Subnet:
- Name: default
- Network: default
- Ip range: 10.148.0.0/20
- Region: asia-southeast1
VM1:
- Subnet: default
- IP: 10.148.0.54
- Zone: asia-southeast1-c
VM2:
- Subnet: default
- IP: 10.148.0.56
- Zone: asia-southeast1-b
Please help me! thank you!
First check if the ARP is resolved for the remote VM you want to ping.
Also check if there is a firewall rule for the default network blocking the communication between the VM's.

Total IP to CIDR Conversion

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)

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)

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.

Resources