rancher / os

Tiny Linux distro that runs the entire OS as Docker containers
https://rancher.com/docs/os/v1.x/en/
Apache License 2.0
6.44k stars 655 forks source link

MAC address confusion #2494

Open kingsd041 opened 6 years ago

kingsd041 commented 6 years ago

RancherOS Version: (ros os version) 1.4.1 Where are you running RancherOS? (docker-machine, AWS, GCE, baremetal, etc.) VirtualBox

Use docker-machine to launch a rancheros, wait for OS to start successfully and check the mac address. We can see that the mac address of eth0 is 08:00:27:f8:5d:1ceth1 is 08:00:27:d4:dd:81

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:f8:5d:1c brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fef8:5d1c/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:d4:dd:81 brd ff:ff:ff:ff:ff:ff
    inet 192.168.99.105/24 brd 192.168.99.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fed4:dd81/64 scope link
       valid_lft forever preferred_lft forever

Then add a third NIC in the virtualbox and restart the OS. At this point, the mac address of eth1 becomes 08:00:27:db:cc:14, and the mac address of eth2 becomes 08:00:27:d4:dd:81

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:f8:5d:1c brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fef8:5d1c/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 08:00:27:db:cc:14 brd ff:ff:ff:ff:ff:ff
    inet 192.168.99.106/24 brd 192.168.99.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fedb:cc14/64 scope link
       valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:d4:dd:81 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::a00:27ff:fed4:dd81/64 scope link
       valid_lft forever preferred_lft forever

I tried to solve this problem by modifying /etc/udev/rules.d/70-persistent-net.rules. But unfortunately, there is no 70-persistent-net.rules file under /etc/udev/rules.d/.

niusmallnan commented 5 years ago

70-persistent-net.rules depends on /lib/udev/write_net_rules, It is a traditional way and no longer popular now.

ID_NET_NAME_PATH is commonly used to name NIC devices, like: enpxxx, ensxxxx. But RancherOS uses rancher.network.interfaces.eth*.dhcp=trye to enable the network by default. In order to be compatible with more scenes, we removed ID_NET_NAME_PATH naming rules. https://github.com/rancher/os/blob/master/images/01-base/Dockerfile#L2

FROM rancher/os-rootfs
RUN ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules  #here 

Refer to: