Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As a Linux admin, I am thoroughly confused. Are you saying that MacOS maintains a separate routing table for each interface?

Typically, a system has only one default route. You can have many interfaces and many routes, but only one default. Otherwise you don't know which default gateway to send a packet to.



The GP is wrong, and your understanding is correct - there is one routing table.


There is one routing table but it can have multiple default gateways:

  fenrir:~ $ uname -a 
  Darwin fenrir 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64
  
  fenrir:~ $ netstat -rn |head 
  Routing tables
  
  Internet:
  Destination        Gateway            Flags        Refs      Use   Netif Expire
  default            172.16.22.254      UGSc           85      732     en0       
  default            192.168.88.1       UGScI           2       49     en2       
  127                127.0.0.1          UCS             0        0     lo0       
  127.0.0.1          127.0.0.1          UH              1     3806     lo0       
  169.254            link#6             UCS             2        0     en0      !
  169.254            link#8             UCSI            0        0     en2      !
If you bind to a specific interface it will use that default gateway:

  fenrir:~ $ traceroute -ni en0 google.com
  traceroute to google.com (216.58.194.142), 64 hops max, 52 byte packets
   1  172.16.22.254  0.565 ms  0.340 ms  0.300 ms
   2  172.16.25.60  0.893 ms  0.727 ms  0.721 ms
   3  172.16.25.0  0.954 ms  0.819 ms  0.815 ms
   4  108.218.244.1  7.422 ms  1.908 ms  3.617 ms
   5  *^C
  fenrir:~ $ traceroute -ni en2 google.com
  traceroute to google.com (216.58.194.142), 64 hops max, 52 byte packets
   1  192.168.88.1  12.399 ms  3.768 ms  0.811 ms
   2  192.168.80.1  1.950 ms  8.322 ms  1.702 ms
   3  172.26.96.161  30.448 ms  393.449 ms  46.537 ms
   4  107.72.199.60  182.826 ms
      107.72.199.36  34.835 ms
      107.72.199.60  50.557 ms
   5  12.83.186.101  52.178 ms  32.536 ms  33.431 ms
   6  12.83.186.85  38.516 ms  51.138 ms  61.687 ms
   7  12.122.5.190  48.626 ms  251.733 ms  38.487 ms
   8  12.122.2.197  58.184 ms  82.183 ms^C
 
You can also also do this do this by IP address

  fenrir:~ $ traceroute -ns 192.168.88.243 google.com
  traceroute to google.com (216.58.194.142) from 192.168.88.243, 64 hops max, 52 byte packets
   1  192.168.88.1  4.658 ms  10.498 ms  3.633 ms
   2  192.168.80.1  4.264 ms  58.660 ms  7.153 ms
   3  172.26.96.161  105.557 ms  41.207 ms  32.243 ms
   4  107.72.199.60  66.562 ms
Which interface is used when IP address / interface is not specified is selected by the Service Order setting in the Network control panel.


You can actually do this on linux pretty easily but it's not the default, it's sometimes called "source routing"

Easy to setup with netplan and systemd-networkd, a little more complex to do manually.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: