LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 08-04-2020, 01:24 AM   #1
postcd
Member
 
Registered: Oct 2013
Posts: 527

Rep: Reputation: Disabled
Can i/how discover subnet IP format from IP range?


Hello,

i have found the IP range 120.76.0.0 - 120.79.255.255 that i want to ban in iptables the way i write x.x.x.x/xx format. Please how to know what that x.x.x.x/xx should be? I have found some online tool where i enter the range and it return it, but unable, these tools like https://www.calculator.net/ip-subnet-calculator.html only have field for single IP and subnet mask.
 
Old 08-04-2020, 01:54 AM   #2
agillator
Member
 
Registered: Aug 2016
Distribution: Mint 19.1
Posts: 419

Rep: Reputation: Disabled
If you do not know what a CIDR is or how to calculate one I seriously question whether you are ready to or should be dealing directly with iptables. Although it is not that difficult it is far too easy to cause serious problems for yourself. I would advise learning more about the basics of iptables (or nftables) and having some understanding and facility with binary before attempting. However, to your question. The CIDR you are looking for is 120.76.0.0/14. A look at the iptables-extensions man page would also show you you really don't need the CIDR. Using the iprange match --src-range will also work.

Last edited by agillator; 08-04-2020 at 01:55 AM.
 
1 members found this post helpful.
Old 08-04-2020, 02:45 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,294
Blog Entries: 3

Rep: Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719
See also:

https://community.spiceworks.com/net...-a-subnet-mask

https://www.cidr.eu/en/ipv4

That is for IPv4. IPv6 is quite different, on many levels.


Then for NFTables, try starting here:

https://wiki.nftables.org/wiki-nftab..._in_10_minutes

https://www.linuxsecrets.com/archlin.../Nftables.html
 
1 members found this post helpful.
Old 08-04-2020, 08:31 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,617

Rep: Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963
Quote:
Originally Posted by postcd View Post
Hello,
i have found the IP range 120.76.0.0 - 120.79.255.255 that i want to ban in iptables the way i write x.x.x.x/xx format. Please how to know what that x.x.x.x/xx should be? I have found some online tool where i enter the range and it return it, but unable, these tools like https://www.calculator.net/ip-subnet-calculator.html only have field for single IP and subnet mask.
Agree with agillator, but again question why someone with more than SIX YEARS experience using iptables needs to ask such questions:
https://www.linuxquestions.org/quest...st-4175678169/
https://www.linuxquestions.org/quest...ps-4175614728/

...among many others that are iptables related. And you asked a similar question THREE YEARS ago, and one before that dealing with subnets and iptables; why can you not apply anything you've been told or learned???
https://www.linuxquestions.org/quest...ed-4175610321/
https://www.linuxquestions.org/quest...em-4175572252/
 
Old 08-05-2020, 02:58 AM   #5
postcd
Member
 
Registered: Oct 2013
Posts: 527

Original Poster
Rep: Reputation: Disabled
:-)
1) go to https://community.spiceworks.com/tools/subnet-calc/ and set Number of subnets 1
2) if one's range is the range of some provider that should be banned, then the provider's range (subnet/CIDR format) may be found like this: go to Linux terminal and do command "whois x.x.x.x|grep route" where x.x.x.x is some IP within the rage. It should show CIDR format with /subnetmask.

Last edited by postcd; 08-05-2020 at 03:05 AM.
 
Old 08-05-2020, 07:58 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,617

Rep: Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963
Quote:
Originally Posted by postcd View Post
:-)
1) go to https://community.spiceworks.com/tools/subnet-calc/ and set Number of subnets 1
2) if one's range is the range of some provider that should be banned, then the provider's range (subnet/CIDR format) may be found like this: go to Linux terminal and do command "whois x.x.x.x|grep route" where x.x.x.x is some IP within the rage. It should show CIDR format with /subnetmask.
Right; that's what you were told in agillators first reply, and were even handed a link to the subnet calculator from Turbocapitalist.

And again: you asked about this SEVEN YEARS AGO, and were handed the commands, because you (apparently) can't put any effort into learning for yourself, or applying what you're told. Is there some point that you're going to be able to do things on your own?
 
Old 08-05-2020, 08:36 PM   #7
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,725

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by postcd View Post
:-)
1) go to https://community.spiceworks.com/tools/subnet-calc/ and set Number of subnets 1
2) if one's range is the range of some provider that should be banned, then the provider's range (subnet/CIDR format) may be found like this: go to Linux terminal and do command "whois x.x.x.x|grep route" where x.x.x.x is some IP within the rage. It should show CIDR format with /subnetmask.
Ish...ARIN and RIPE usually publish the CIDR of the containing range. Other registries are less consistent.
I downloaded two perl scripts — I don’t recall from where — cidr.pl and cidr_range.pl that will convert ranges to cidr notation and vice versa.
DDG is your friend. Try searching for either script name. Let us know if you can’t find them.
 
Old 08-06-2020, 08:04 AM   #8
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,617

Rep: Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963
Quote:
Originally Posted by scasey View Post
Ish...ARIN and RIPE usually publish the CIDR of the containing range. Other registries are less consistent. I downloaded two perl scripts — I don’t recall from where — cidr.pl and cidr_range.pl that will convert ranges to cidr notation and vice versa. DDG is your friend. Try searching for either script name. Let us know if you can’t find them.
I wish you luck; check the OP's posting history.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] VLAN with 2 Router and 2 Subnet - Is device in different subnet works? velusawme Linux - Networking 2 07-23-2011 10:16 AM
Cant browse computer of one subnet from another subnet dearleza Linux - Networking 3 07-05-2011 04:31 PM
Discover DHCP clients on a subnet crackpipe Linux - Security 19 08-05-2009 04:53 PM
discover all hosts in ipv6 subnet and their addresses ineya Linux - Networking 5 12-13-2008 05:21 AM
Can IP from different subnet be configured on another subnet russell Linux - Networking 1 08-23-2002 01:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration