NETWORKING: PIN THE TAIL ON THE HEADLESS RASPBERRY PI

eager to get deeper into robotics after dipping my toe in the water with my BB-8 droid, I purchased a Raspberry Pi 3 model B. The first step was to connect to it. but while it has built-in 802.11n wireless, I at first didn’t have a wireless access point, though I eventually did get one. That indicated I went through different ways of finding it and connecting to it with my desktop computer. definitely there are others seeking to do the same so let’s take a look at the secret incantations used to connect a Pi to a computer directly, and indirectly.

Why connect to the Pi from my desktop computer? After all, there are small monitors and keyboards that hackers frequently use to make Pi laptops and Pi tablets. Since I was going to be embedding the Pi in various robots,  I saw no need to purchase a separate monitor and keyboard for it, but I did look a little into doing so.

My desktop’s monitor uses a VGA connector but the VGA-to-HDMI adapter I gotten along with the Pi didn’t work. Also, my desktop’s ancient KeyTronic keyboard uses a PS/2 connector so that wasn’t usable either. though PS/2-to-USB adaptors do exist, my research showed that I’d need the one that has USB smarts in it, as my keyboard predates USB and has no such electronics of its own. (But it does have sweet, deep tactile keys!) My Pi would remain headless, and I’d program it by connecting to it from my desktop computer.

Connecting directly by means of Ethernet Cable

My home modem was also ancient, having no wireless. It also had only one Ethernet port. That indicated I could connect my desktop computer either to the modem or to the Raspberry Pi but not both at the same time. So on unboxing the Pi, the only way to connect it to my computer was to unplug the Ethernet cord from the modem and plug it into the Pi instead. That indicated no Internet access while working with the Pi, hardly ideal, but good enough to see if the Pi worked at all.

But for my computer to speak to the Pi, I needed the Pi’s IP address. For those not familiar with IP addresses, they consist of 4 numbers ranging from 0 to 255 separated by dots. উদাহরণ স্বরূপ:

169.254.95.208

It’s really a 32-bit number but it’s written that way for readability.

Network and Sharing center in Windows
IP address and subnet mask

Going to the Windows control panel on my desktop and then the Network and Sharing Center, I could see that a network now existed.

Clicking on view status and going deeper I found some beneficial information. The first was the IP address of the desktop computer, 169.254.95.208. The IPv4 tells me that it’s using Internet Protocol version 4. The IP addresses in IPv6 differ at least in that they’re four times as long.

Further, the presence of the IPv4 Subnet Mask, 255.255.0.0 told me that a subnet, or subnetwork, had been formed between the two machines. A subnet is a group of machines making up a smaller network that may or may not be a part of a larger one. Their IP addresses all start with the same binary values, though just how lots of bits at the beginning they have in common varies. how do you know which bits are common?

Using the subnet mask
That’s where the subnet mask comes in. To find out which bits, take the subnet mask and do a bitwise and with the IP address of a maker on that subnet. As the diagram shows, the result in my case was 169.254.0.0, indicating that the Pi’s IP address must start with 169.254. another way of writing the subnet mask is in CIDR notation. In CIDR notation the IP address is followed by a / and then the number of shared bits. In this case it would be 169.254.0.0/16. The last two numbers are zeros but they need not be considering that the 16 tells you what to keep. This CIDR notation will come in helpful shortly.

Though the 169.254 was shared, that still left 65,536 (256×256) possible combinations for the two remaining numbers. To scan the network, going through every possible combination of numbers, I used nmap, downloadable from nmap.org.

‘nmap -sn’ scan results
As shown in the snapshot, I ran it in a cygwin window though there are GUI versions available too. I used the following command line.

nmap -sn 169.254.0.0/16

Note that the subnet mask is given using CIDR notation. The section about the Raspberry Pi that you see in the snapshot appeared after around 10 minutes, indicating that it took that long to scan from 169.254.0.0 to 169.254.37.77, the Pi’s IP address. even though that was what I was looking for, I left it going anyway and the full scan took just over forty-four minutes. during that time it also found my desktop computer, the host from which it was doing the scan. had the Pi’s IP address been 169.254.255.255 then it would have taken the full forty-four minutes before finding it.

The Pi’s IP address continued to be 169.254.37.77 across shutdowns and so scanning again was not necessary.

Starting Up A terminal and VNC DesktopSSH টার্মিনাল জন্য PUTTY
VNC ডেস্কটপ

এখন আমি এটি সংযুক্ত ছিলাম, আমাকে ডেস্কটপ কম্পিউটারে পিআইটিতে একটি নিরাপদ শেল (এসএসএইচ) চলমান একটি টার্মিনাল প্রয়োজন ছিল। টার্মিনাল সেট আপ করা কেবল জনপ্রিয় পুটি প্রোগ্রাম ডাউনলোড এবং এটি চলমান একটি ব্যাপার ছিল। সেশন বিভাগে, আমি পিআই এর আইপি ঠিকানা, পোর্ট 22 এ ভরাট করেছি, এবং নিশ্চিতভাবেই SSH নির্বাচন করা হয়েছিল। যে একটি লগইন প্রম্পট সঙ্গে একটি টার্মিনাল উইন্ডো খোলা। ডিফল্ট ব্যবহারকারীর নাম পাই এবং পাসওয়ার্ডটি রাস্পবেরী। অবশ্যই আমি প্রথম জিনিসটি পাসওয়ার্ড পরিবর্তন করার জন্য পাসডাব্লু ইউটিলিটি চালানো হয়েছিল।

বিকল্পভাবে আপনি VNC ব্যবহার করে একটি গ্রাফিকাল টার্মিনাল পেতে পারেন। এটি একটি গ্রাফিকাল ডেস্কটপ যা আপনার ডেস্কটপ কম্পিউটারে একটি উইন্ডোতে সঞ্চালিত হয় তবে এটি সত্যিই PI তে একটি টার্মিনাল।

একটি বেতার রাউটার ব্যবহার করে ইথারনেট এর মাধ্যমে সংযোগ

আমার পিআই পাওয়ার পরে দীর্ঘ ছিল না যে আমি একটি বেতার রাউটার / ফাইবার মোডেম কম্বোতে স্যুইচ করার সিদ্ধান্ত নিয়েছিলাম। একটি বোনাস হিসাবে, এই আপগ্রেড এছাড়াও একাধিক ইথারনেট পোর্ট রয়েছে। আমি আমার ডেস্কটপ কম্পিউটারটি বেতার ব্যবহার করতে সেট আপ করি, কিন্তু আমি এখনো পাইয়ের জন্য একই কাজ করতে পারিনি। ওয়্যারলেস সেট আপ করার জন্য PI তে আমাকে কিছু কনফিগারেশন করতে হয়েছিল, তাই আমি প্রথমে ইথারনেট ব্যবহার করে সংযোগ স্থাপন করতে হয়েছিল।

একটি ব্রাউজারে রাউটার নেটওয়ার্ক তথ্য
ইথারনেটের সাথে রাউটারের সাথে সংযুক্ত হওয়ার সাথে সাথে কোনও স্ক্যানিং জড়িত ছিল না এমন সরাসরি-সংযোগ পদ্ধতির তুলনায় অনেকগুলি সহজ ছিল। একবার আমি একটি ইথারনেট তারের ব্যবহার করে পাইটি সংযুক্ত করলাম, আমি কেবল আমার ডেস্কটপ কম্পিউটারে একটি ব্রাউজারটি তৈরি করেছি এবং রাউটারের আইপি ঠিকানাটিকে ব্রাউজারের URL বারে টাইপ করেছি। এটি 192.168.1.1 বা 192.168.2.1 এর মতো একটি ঠিকানা, তবে এটির সামনে http: // এর সাথে, যদিও কিছু ব্রাউজার http: // এর প্রয়োজন হয় না। আপনার রাউটার / মডেম ম্যানুয়াল চেক করুন।

আপনি যা দেখেন তা আপনার মোডেমের উপর নির্ভর করে, তবে খনিটি পিআই এর আইপি অ্যাড্রেস, 192.168.2.14 এর সাথে নীচে একটি নেটওয়ার্ক গ্রাফ প্রদর্শন করেছে। যেহেতু আমি উপরে বর্ণিত হিসাবে PUTTY ব্যবহার করে একটি টার্মিনাল আনতে সক্ষম ছিল।

আপনি যদি আপনার পিআই এবং মডেমের মধ্যে ইথারনেট ব্যবহার করতে চান তবে আপনি সম্পন্ন করেন। কিন্তু আমি বেতার যেতে চেয়েছিলাম যাতে আমার রোবটগুলি একটি পিছনের ইথারনেট তারের ছাড়াই ঘুরে বেড়ায়। এখন আমি পাইতে একটি টার্মিনাল ছিল যা আমি পরবর্তী ধাপে যেতে পারতাম।

বেতার সংযুক্ত

রাস্পবেরী পাই 3 মডেল বি বেতার অন্তর্নির্মিত, তবে আপনার যদি বেতার ছাড়াই একটি সংস্করণ থাকে তবে আপনি একটি ওয়্যারলেস ডংল পেতে পারেন যা PI এর USB পোর্টগুলির মধ্যে একটিতে প্লাগ করে। আপনি হেডলেস পাই ওয়্যারলেস-তে সংযোগ করার আগে, আপনাকে অবশ্যই উপরের পদ্ধতির একটি ব্যবহার করে এটিতে সংযোগ করতে হবে এবং পিআই-তে কিছু কনফিগারেশন করতে হবে।

আমি একটি টার্মিনাল আনা এবং উপরে বর্ণিত হিসাবে লগ ইন। আমি কনফিগারেশন ফাইল /etc/wpa_supplicant/wpa_supplicant.conf এ আমার বেতার নেটওয়ার্ক নাম এবং নেটওয়ার্ক পাসওয়ার্ডটি রাখতে হবে। কিন্তু নিরাপত্তার কারণে, আমি পাসওয়ার্ডটি প্লেইন পাঠ্যে থাকতে চাই না।

WPA_PSPSPHRESE এবং সম্পাদনা WPA_SUPPLICANT.CONF ব্যবহার করে
সম্পাদনা করা WPA_SUPPLICANT.CONF.
তাই আমি wpa_passphrase “bobsnetname” “bobsnetpassword” দৌড়ে গিয়ে আউটপুটকে হাইলাইট করেছিলাম, যা এই টার্মিনালে ক্লিপবোর্ডে হাইলাইট করা পাঠ্যকে কপি করে। “bobsnetname” এবং “bobsnetpassword” অবশ্যই কল্পিত হয়।

আমি তারপরে /etc/wpa_supplicant/wpa_supplicant.conf সম্পাদনা এবং ডান ক্লিক করে ক্লিপবোর্ড থেকে পেস্ট। পেস্ট পাঠ্যটি এখনও পরিষ্কার পাঠ্যে পাসওয়ার্ডের সাথে একটি লাইন অন্তর্ভুক্ত করেছে। এটি মন্তব্য করা হয়েছিল কিন্তু তবুও দৃশ্যমান, তাই আমি এটি মুছে ফেলা।

সংরক্ষণের পরে এবং সম্পাদককে প্রস্থান করার পরে আমি ইথারনেট তারের সংযোগ বিচ্ছিন্ন করেছিলাম। WPA-Supplicant নামে একটি চলমান প্রোগ্রামটি এটি লক্ষ্য করার জন্য এবং বেতার যা পেতে এবং বেতার পেতে পরে কয়েক সেকেন্ড পরে নেওয়া উচিত। এবং তাই কয়েক সেকেন্ড অপেক্ষা করার পর আমি পিং গুগল ডটকম দৌড়েছিলাম। এটা কাজ করেছে. পিআই ওয়্যারলেস সংযুক্ত ছিল।

যদি এটি না হয় তবে আমি সুডো WPA_CLI পুনর্গঠন চালিয়ে এটি নিজে এটি পুনরায় চালু করতে পারতাম। এটি ইন্টারফেস নামটিও আমার ক্ষেত্রে Wlan0 রিপোর্ট করে।

চলমান ‘ifconfig wlan0’
অতিরিক্তভাবে এটি পরীক্ষা করে এবং পিআই এর আইপি ঠিকানা পেতে, আমি ifconfig wlan0 দৌড়ে এবং INT addr পাশে আইপি ঠিকানাটি দেখেছি। সেখানে ছিল এবং এর সাথে আমি পাইটিকে সংযুক্ত করতে পারি এবং প্রোগ্রামিং রোবটগুলি শুরু করতে পারি।

যারা আমার রাস্পবেরী পিআই সংযোগে আমার অভিজ্ঞতা ছিল, কিন্তু আমরা জানি যে হ্যাকডেতে প্রচুর রাস্পবেরী পাই ব্যবহারকারী রয়েছে। আপনি কোন পদ্ধতি ব্যবহার করেছেন, আপনি কোন ফাঁদ খুঁজে পেয়েছেন এবং আপনার কাছ থেকে বের হওয়ার জন্য আপনার কোন ধারণা আছে? আমাদের মন্তব্যে জানতে দিন যাতে অন্যরাও তাদের মধ্যে পড়ে না।

Leave a Reply