Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
ある日、突然ホスト名が “MacBookPro” になった話
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Yoshimasa Niwa
October 30, 2024
350
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ある日、突然ホスト名が “MacBookPro” になった話
ある日、突然ホスト名が “MacBookPro” になった話
Yoshimasa Niwa
October 30, 2024
More Decks by Yoshimasa Niwa
See All by Yoshimasa Niwa
SwiftUI API Design Lessons
niw
2
730
TextKit 2 時代の iOS のキーボードとテキスト入力と表示のすべて
niw
6
5.3k
Xcode が遅い! とにかく遅い!! 遅い Xcode をなんとかする方法
niw
2
10k
実践 iOS オープンソースプロジェクトの始め方
niw
6
3.6k
iOS のキーボードと文字入力のすべて
niw
14
3.7k
Getting started with making macOS utility app using private APIs
niw
3
3.1k
アプリの国際化の舞台裏
niw
11
8.1k
Lessons Learned
niw
6
5.5k
Getting Started with Scalding, Storm and Summingbird
niw
9
3.1k
Featured
See All Featured
Un-Boring Meetings
codingconduct
0
410
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
500
Optimising Largest Contentful Paint
csswizardry
37
3.9k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
69
65k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
230
Unsuck your backbone
ammeep
672
58k
Building a Scalable Design System with Sketch
lauravandoore
464
34k
Prompt Engineering for Job Search
mfonobong
0
450
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
57k
GitHub's CSS Performance
jonrohan
1033
470k
Transcript
͋Δɺಥવϗετ໊͕ “MacBookPro” ʹͳͬͨ @niw 10/30/2024 — Tokyo, Japan ΰϦϥ.vim #33
Yoshimasa Niwa @niw
Vim ϢʔβʔͰ͢!
͋Δɺಥવϗετ໊͕ “MacBookPro” ʹͳͬͯ͠·ͬͨ
None
ͳͥ?
None
System Configuration Parameters macOS ͷઃఆ scutil --get --set ͰҎԼͷ3ͭઃఆ͕Ͱ͖Δ
ComputerName LocalHostName HostName
System Configuration Parameters macOS ͷઃఆ ComputerName Λ௨ৗઃఆ͢Δ LocalHostName σϑΥϧτͰ ComputerName
HostName ௨ৗ ”” (ۭനจࣈྻ) ɻDNS ͷٯҾ͖Ͱܾఆɻ hostname(1) gethostname(3) ͷ͜ͷ HostName
ͭ·Γ DNS ٯҾ͖͕ “MacBookPro” ʹͳ͍ͬͯΔ!
Α͋͘Δϧʔλͷڍಈ DNS ͷٯҾ͖ొ Α͋͘Δϧʔλ DHCP Ͱ IPv4 ΞυϨεΛΓͭͭɺDNS ͷϓϩΩγͱΩϟογϡΛ͢Δɻ ͜ͷDNS
ϓϩΩγ͕ͨ·ʹٯҾ͖ొΛ͢ΔλΠϓͷͷ ͕͋Δɻ dnsmasq ͳͲ͕࣮ྫɻ
https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html
None
None
None
DHCP Ͱ “MacBookPro” ͱ ͍͏ϗετ໊Λཁٻ͍ͯ͠Δ?
DHCPREQUEST Option 12 DHCP Ͱϗετ໊Λࢦఆ͢Δ ࠓ࣌ͷ DHCP RFC 2131
Dynamic Host Con fi guration Protocol Ͱنఆ͞ΕΔ ॴҦαʔόʔɾΫϥΠΞϯτϞσϧͰɺΫϥΠΞϯτͷཁٻ ʹαʔόʔ͕ IP ΞυϨε DNS αʔόͷΞυϨεΛฦ͢ Δ
-------- ------- | | +-------------------------->| |<-------------------+ | INIT- | |
+-------------------->| INIT | | | REBOOT |DHCPNAK/ +---------->| |<---+ | | |Restart| | ------- | | -------- | DHCPNAK/ | | | | Discard offer | -/Send DHCPDISCOVER | -/Send DHCPREQUEST | | | | | | DHCPACK v | | ----------- | (not accept.)/ ----------- | | | | | Send DHCPDECLINE | | | | REBOOTING | | | | SELECTING |<----+ | | | | / | | |DHCPOFFER/ | ----------- | / ----------- | |Collect | | | / | | | replies | DHCPACK/ | / +----------------+ +-------+ | Record lease, set| | v Select offer/ | timers T1, T2 ------------ send DHCPREQUEST | | | +----->| | DHCPNAK, Lease expired/ | | | | REQUESTING | Halt network | DHCPOFFER/ | | | | Discard ------------ | | | | | | ----------- | | +--------+ DHCPACK/ | | | | Record lease, set -----| REBINDING | | | timers T1, T2 / | | | | | DHCPACK/ ----------- | | v Record lease, set ^ | +----------------> ------- /timers T1,T2 | | +----->| |<---+ | | | | BOUND |<---+ | | DHCPOFFER, DHCPACK, | | | T2 expires/ DHCPNAK/ DHCPNAK/Discard ------- | Broadcast Halt network | | | | DHCPREQUEST | +-------+ | DHCPACK/ | | T1 expires/ Record lease, set | | Send DHCPREQUEST timers T1, T2 | | to leasing server | | | | ---------- | | | | |------------+ | +->| RENEWING | | | |----------------------------+ ---------- Figure 5: State-transition diagram for DHCP clients https://datatracker.ietf.org/doc/html/rfc2131
DHCPREQUEST Option 12 DHCP Ͱϗετ໊Λࢦఆ͢Δ ΫϥΠΞϯτ DHCPREQUEST ΛૹΓɺαʔόʔ DHCPACK Ͱ
IPΞυϨεΛฦ͢ DHCPREQUEST ʹΦϓγϣϯ͕͋ΓɺRFC 1533 Ͱنఆ͞ ΕΔ Host Name Option (Code = 12) Ͱϗετ໊ΛࢦఆͰ͖Δ
None
“MacBookPro” ͕ Option 12 Ͱࢦఆ͞Ε͍ͯΔ!
͍Ζ͍Ζ࿙ΕͯΔ Wi-Fi ͷϓϥΠόγʔ Wi-Fi ΘΓͱઅૢͳͦ͘ͷΜʹ͋ΔͷΛͬͯ͠·͏ Wi-Fi Ͱ IPv4 ௨৴͕Ͱ͖Δͷ DHCP
͕͋Δ͔Β ΫϥΞϯτ DHCP ʹ͍Ζ͍ΖใΛͯ͠͠·ͬͯΔ ϗετ໊͕ʮ୭ʑͷPCʯͩͱɺOption 12 ʹ୭ʑͷ෦͕ ೖ͍ͬͯͨΓͯ͠ɺIPΞυϨε͔Βݸਓ͕ಛఆͰ͖ΔՄೳੑ ͋Δ
͍Ζ͍Ζ࿙ΕͯΔ Wi-FiͷϓϥΠόγʔ ࣮ macOS 15 ͔Β DHCP ΫϥΠΞϯτͷ࣮͕มΘͬͯ ͍Δɻ σϑΥϧτͰɺWi-Fi
ܦ༝ͷ DHCPREQUEST ͷϗετ໊ ৗʹσόΠεͷछྨʹͳΔɻྫ͑ɺMacBookPro ɺ MacBookAir
https://github.com/apple-oss-distributions/bootp/blob/ main/IPCon fi guration.bproj/dhcp.c#L473-L487
https://github.com/apple-oss-distributions/bootp/blob/ main/IPCon fi guration.bproj/ipcon fi gd.c#L5405-L5408
https://github.com/apple-oss-distributions/bootp/blob/main/bootplib/interfaces.c#L872-L880
#define LOCAL_ADMIN 0x2 return addr->addr[0] & LOCAL_ADMIN) != 0;
2nd LSB of 1st octet of OUI MACΞυϨεϥϯμϚΠθʔγϣϯ iPhone
Mac ͷ MAC ΞυϨεσϑΥϧτͰϥϯμϚΠζ ͞Ε͍ͯΔ MAC ΞυϨε 64-bit ͋ͬͯɺ࠷ॳͷ 32-bit ϕϯμʔ͝ ͱʹܾ·͍ͬͯΔ ͜ΕΛ OUIs (Organizationally Unique Identi fi ers) ͱ͍͏
2nd LSB of 1st octet of OUI MACΞυϨεϥϯμϚΠθʔγϣϯ ࠷ॳͷόΠτͷԼ͔Β2൪ͷϏοτ OUI
ͷҰ෦ OUI ϝʔΧʔ͝ͱʹൃߦ͞Ε͍ͯΔ ·͔͞ɺApple ಛఆͷ OUI ϨϯδΛશ෦͍࣋ͬͯΔ?
IEEE 802-2001
2nd LSB of 1st octet of OUI MACΞυϨεϥϯμϚΠθʔγϣϯ ͭ͡ɺOUI ͷ࠷ॳͷόΠτͷԼ2Ϗοτ༧͞Ε͍ͯΔ
Լ͔Β1Ϗοτ༻్͕ܾ·͍ͬͯΔ Լ͔Β2ϏοτΊ0ͱܾ·͍ͬͯΔ ͭ·Γɺਖ਼نͷOUIͰɺԼ͔Β2Ϗοτ͕1ʹͳΔ͜ͱͳ ͍
None
$ irb irb(main):001> "f6:06:3a:90:bc:fe".split(/:/) .map{|s| "%08b" % s.to_i(16)}.join(" ") =>
"11110110 00000110 00111010 10010000 10111100 11111110"
None
$ irb irb(main):001> "f0:00:00:00:00:00".split(/:/) .map{|s| "%08b" % s.to_i(16)}.join(" ") =>
"11110000 00000000 00000000 00000000 00000000 00000000"
ϗετ໊͕ “MacBookPro” ʹͳͬͨཧ༝ ·ͱΊ MACΞυϨεͷϥϯμϚΠθʔγϣϯͷख๏ͰMACΞυϨε ͷ࠷ॳͷΦΫςοτͷԼ͔Β2Ϗοτ͕1ʹͳΔ͜ͱͰɺ DHCPΫϥΠΞϯτ͕ϓϥΠϕʔτΞυϨεͱஅ͠ɺσό ΠεͷϞσϧ໊ΛDHCPREQUESTͷOption 12ʹϗετ໊ͱ͠ ͯࢦఆ͢Δ͜ͱͰɺDHCPαʔόͱ࿈ಈ͢ΔDNSαʔό͕ͦ
ͷϞσϧ໊ΛٯҾ͖ొͨ݁͠ՌɺDNSΫϥΠΞϯτͷٯҾ ͖ղܾͰϞσϧ໊͕ฦ͖ͬͯͨҝ