Friday, November 22, 2024

network – How do I manually configure the IP number and gateway IP for a device connected to my Mac on a shared Ethernet connection?

I have a device running embedded Linux and busybox that does not have WiFi, only Ethernet.

When at home I successfully connect that device to the same router (through a switch) as my Mac and configure it using ifconfig eth0 192.168.1.63 && route add default gw 192.168.1.254. (busybox on the device does not include the udhcp client.)

But when traveling I need to connect the device directly to my Mac with an Ethernet cable, through an Anker USB 3 to Ethernet adapter. I enabled Internet Sharing on my Mac.

Inside System Information under Network the Ethernet adapter shows as “AX88179A”. It shows “IPv4 Addresses: 169.254.2.40”.

enter image description here

Here are the results from ifconfig en8:

en8: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
    options=404<VLAN_MTU,CHANNEL_IO>
    ether a0:ce:c8:74:6c:ef
    inet6 fe80::4bc:d253:1602:7ba9%en8 prefixlen 64 secured scopeid 0x1d
    inet 169.254.128.214 netmask 0xffff0000 broadcast 169.254.255.255
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect (100baseTX <full-duplex>)
    status: active

My questions are:

How to I assign an IP number to the device that the Mac will be able to find a route to?

How do I determine the gateway IP number to use on the device?

Will the Mac (properly configured) route packets to my embedded device? (eg. Can I successfully ping a host outside the subnet from the device?)

How do I determine the IP number for the device that I can use on hosts outside this subnet? Perhaps, that’s not possible, since only the Mac–which is acting as a router–is visible.

So can I configure the Mac to forward packets for specified ports to my device? (This would allow connect GDB running on a computer that is not on the subnet to GDB Server running on the device with an specific port. I would specify the Mac’s IP number in GDB.)

Update: Seamus‘s comment suggests I assign one IP number to my Mac and one to the device, both on the same subnet. I guess as long as both start with 169.254. they will be on the same subnet, since the subnet mask is 255.255.0.0.

But what does the IP number 169.254.128.214 in the results of ifconfig en8 indicate? Is that already assigned to my Mac? Or do I need to choose a different one for my Mac? And what IP number do I use for the gateway that I specify on the embedded device?

Related Articles

Latest Articles