[Swan-dev] extract MAC address from "ip -o link sow dev eth0" - awk

Lennart Sorensen lsorense at csclub.uwaterloo.ca
Tue Sep 24 14:22:10 UTC 2019


On Tue, Sep 24, 2019 at 08:44:35AM +0200, Antony Antony wrote:
> Interesting, I am not sure why it is missing for me. I use nsenter.
> May be differnce between "ip netns" and "nsenter". nsenter give access to
> mountns and utsns.
> 
> When I look inside namespace using nsenter. I see the host's  
> /sys/class/net/ and there is no eth0 there.
> 
> /sys/class/net/ sudo /usr/bin/nsenter 
> --mount=/run/mountns/east-xauth-pluto-13 
> --net=/run/netns/east-xauth-pluto-13 --uts=/run/utsns/east-xauth-pluto-13 
> /bin/bash
> 
> ip link show dev eth1
> 144: eth1 at if145: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
>     link/ether 82:1d:f3:3f:2c:84 brd ff:ff:ff:ff:ff:ff link-netnsid 0
> 
> ls -lt /sys/class/net/eth0
> ls: cannot access 'ls': No such file or directory
> 
> my theory is host end exist in /sys/class/net ; ie ifindex 145 exist but not 
> 144
> 
> grep 145 /sys/class/net/*/ifindex
> /sys/class/net/heaste135647/ifindex:145 
> 
> grep 144  /sys/class/net/*/ifindex
> is empty 

I used 'docker exec' to run a shell in the container to see what the
container sees.  I did not try to manually get at docker's namespace.

-- 
Len Sorensen


More information about the Swan-dev mailing list