
How to convert communities
I'm reading the Practical BGP book, and it shows an example of the below where the router is not using the #ip bgp-community new-format command. So when you put in the community 200:666 (as shown below), it coverts it to decimal and gets 13107866. Can someone tell me how to solve the maths on this please? I want to know how to go from 200:666 and reach 13107866. I would also want to know how to do it the other way around.
router(config)#ip community-list 1 permit 200:666
router#sh ip community-list 1
Community standard list 1
permit 13107866
Edit: I may have figured this out. So it's 2 bytes for each number right? If I convert them to binary and make them one big string?
So the numbers in the first left brackets = 200, and the second brackets = 666.
[0000000/11001000]/[00000010/10001111]
Then I bung this entire 32 character number into the scientific calculator as binary and convert it to dec. = 13107866. Done
Comments
That's correct
You need to convert the both values from decimal to binary. Then fill the 1 byte (<255) values with 00000000 so it's a 2 byte value. After that you can combine it as a 4 byte value and convert them back to decimal.
Decimal to binary conversion
200: 1001000 -> 2byte 000000001001000
666: 0000001010011010
Combine them and convert to decimal again
0000000010010000000001010011010 = 13107866
Thanks.