add local ip netns add remote ip netns list > remote > router > local # vethを生やして、各ノードにぶら下げる ip link add name veth1-local type veth peer name veth1-remote ip link set veth1-local netns local ip link set veth1-remote netns remote # 各終端にIPアドレスを振って、upする ip netns exec local ip addr add 10.0.0.1/23 dev veth1-local ip netns exec remote ip addr add 10.0.1.1/23 dev veth1-remote ip netns exec local ip link set veth1-local up ip netns exec remote ip link set veth1-remote up
link set lo up ip netns exec remote ip link set lo up # 親コンテキストでrsyslogdを終了して、local ノードでrsyslogdを起動 systemctl stop rsyslog ip netns exec local /sbin/rsyslogd # remoteコンテキストでUDPパケットを投げてみる ip netns exec remote python3 syslog_client.py 10.0.0.1 tail -1 /var/log/messages > Dec 15 07:24:26 10.0.1.1 190 # ipアドレスを差し替えて、UDPパケットを投げてみる ip netns exec remote ip addr del 10.0.1.1/23 dev veth1-remote ip netns exec remote ip addr add 10.0.1.2/23 dev veth1-remote ip netns exec remote python3 syslog_client.py 10.0.0.1 > Dec 15 07:24:48 10.0.1.2 190
modprobe -a dummy ip link add name eth10 type dummy ip addr add 172.16.2.1/23 dev eth10:2 ip addr add 172.16.3.1/23 dev eth10:3 echo “<12> test ” | nc -u -w 1 -s 172.16.2.1 172.16.3.1 514 ip addr delete 172.16.2.1/23 dev eth10:2 ip addr delete 172.16.2.2/23 dev eth10:2 ... ip link delete eth10