Linux에서 가상으로 IP 주소 중복 환경 구축
소개
Linux에서 brctl
및 netns
를 사용하여 IP 주소가 중복된 호스트가 있는 환경을 가상으로 구축합니다.
필요한 것
건설
가상 스위치 만들기
brctl addbr yabai
ip link set dev yabai up
ip a a 192.168.100.10/24 dev yabai
veth (가상 LAN 케이블) 만들기
ip link add y-to-ns1 type veth peer name ns1-to-y
ip link add y-to-ns2 type veth peer name ns2-to-y
가상 호스트 만들기
ip netns add ns1
ip netns add ns2
가상 배선
ip link set ns1-to-y netns ns1
ip link set ns2-to-y netns ns2
brctl addif yabai y-to-ns1
brctl addif yabai y-to-ns2
링크 업 + IP 주소 할당
ip link set dev y-to-ns1 up
ip link set dev y-to-ns2 up
ip netns exec ns1 ip link set dev ns1-to-y up
ip netns exec ns1 ip addr add 192.168.100.4/24 dev ns1-to-y
ip netns exec ns2 ip link set dev ns2-to-y up
ip netns exec ns2 ip addr add 192.168.100.4/24 dev ns2-to-y # dup!
명령을 모은 사람
brctl addbr yabai
ip link set dev yabai up
ip a a 192.168.100.10/24 dev yabai
ip link add y-to-ns1 type veth peer name ns1-to-y
ip link add y-to-ns2 type veth peer name ns2-to-y
ip netns add ns1
ip netns add ns2
ip link set ns1-to-y netns ns1
ip link set ns2-to-y netns ns2
brctl addif yabai y-to-ns1
brctl addif yabai y-to-ns2
ip link set dev y-to-ns1 up
ip link set dev y-to-ns2 up
ip netns exec ns1 ip link set dev ns1-to-y up
ip netns exec ns1 ip addr add 192.168.100.4/24 dev ns1-to-y
ip netns exec ns2 ip link set dev ns2-to-y up
ip netns exec ns2 ip addr add 192.168.100.4/24 dev ns2-to-y # dup!
검증
$ sudo arping -I yabai 192.168.100.4 -c 1
ARPING 192.168.100.4 from 192.168.100.10 yabai
Unicast reply from 192.168.100.4 [B2:37:33:07:94:33] 0.562ms
Unicast reply from 192.168.100.4 [A2:7E:B4:EC:B1:9D] 0.581ms
Sent 1 probes (1 broadcast(s))
Received 2 response(s)
다른 MAC 주소의 호스트에서 Reply가 올 경우 성공합니다.
Reference
이 문제에 관하여(Linux에서 가상으로 IP 주소 중복 환경 구축), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/aoki/items/f67c72f393b24a2b0871
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
brctl addbr yabai
ip link set dev yabai up
ip a a 192.168.100.10/24 dev yabai
ip link add y-to-ns1 type veth peer name ns1-to-y
ip link add y-to-ns2 type veth peer name ns2-to-y
ip netns add ns1
ip netns add ns2
ip link set ns1-to-y netns ns1
ip link set ns2-to-y netns ns2
brctl addif yabai y-to-ns1
brctl addif yabai y-to-ns2
ip link set dev y-to-ns1 up
ip link set dev y-to-ns2 up
ip netns exec ns1 ip link set dev ns1-to-y up
ip netns exec ns1 ip addr add 192.168.100.4/24 dev ns1-to-y
ip netns exec ns2 ip link set dev ns2-to-y up
ip netns exec ns2 ip addr add 192.168.100.4/24 dev ns2-to-y # dup!
brctl addbr yabai
ip link set dev yabai up
ip a a 192.168.100.10/24 dev yabai
ip link add y-to-ns1 type veth peer name ns1-to-y
ip link add y-to-ns2 type veth peer name ns2-to-y
ip netns add ns1
ip netns add ns2
ip link set ns1-to-y netns ns1
ip link set ns2-to-y netns ns2
brctl addif yabai y-to-ns1
brctl addif yabai y-to-ns2
ip link set dev y-to-ns1 up
ip link set dev y-to-ns2 up
ip netns exec ns1 ip link set dev ns1-to-y up
ip netns exec ns1 ip addr add 192.168.100.4/24 dev ns1-to-y
ip netns exec ns2 ip link set dev ns2-to-y up
ip netns exec ns2 ip addr add 192.168.100.4/24 dev ns2-to-y # dup!
$ sudo arping -I yabai 192.168.100.4 -c 1
ARPING 192.168.100.4 from 192.168.100.10 yabai
Unicast reply from 192.168.100.4 [B2:37:33:07:94:33] 0.562ms
Unicast reply from 192.168.100.4 [A2:7E:B4:EC:B1:9D] 0.581ms
Sent 1 probes (1 broadcast(s))
Received 2 response(s)
다른 MAC 주소의 호스트에서 Reply가 올 경우 성공합니다.
Reference
이 문제에 관하여(Linux에서 가상으로 IP 주소 중복 환경 구축), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/aoki/items/f67c72f393b24a2b0871텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)