![]() disconnecting the cable makes them stop flowing for comparison: "internal" pings (from a wired interface to its own IP address) flow even without a cable.My tests indicate these pings really use the cable. The address 192.168.1.6 is not assigned to any interface in the default network namespace and 192.168.1.5 is not assigned in the non-default namespace.Īnd this is it. Prints (among other lines) 192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.5Īnd this command ip netns exec "$netns" ip route show In my Debian 10 sane routes appear automatically. Ip netns exec "$netns" ip link set dev lo upĬheck routes. Ip netns exec "$netns" ip link set dev "$dev2" up I bring it up just in case, because in general programs may want to rely on it. The namespace contains its own loopback device lo. Physically connect the two interfaces with a cable, if not yet done.īring the interfaces up. Ip netns exec "$netns" ip address add 192.168.1.6/24 dev "$dev2"Ĭonfirm the two devices are where they should be, with the right IP addresses. ip link set dev "$dev2" netns "$netns"Īssign IP addresses. Here I choose to move $dev2 to the new namespace. ip link set dev "$dev1" downĪdd one of the devices to the new namespace (it will disappear from the default namespace). ![]() ip netns add "$netns"īring the devices down in the default namespace. Here ns1 is an arbitrary name for a namespace eth1 and eth2 are the devices you want to use. This answer uses ip netns exec … every time we need to run something in a non-default network namespace.ĭefine useful variables. ![]() It's possible to run a shell this way then everything you run from the shell will use the network namespace.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |