In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the knowledge of "how to create linux namespaces". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The system calls clone to add CLONE_NEWNET
Used to isolate network-related resources, which allows each network namespace to have its own network device, IP address, IP routing table, / proc/net directory, port number, and so on
From a network namespace perspective, each container has its own network device (virtual) and an application used to bind its own network port number. The appropriate routing rules on the host can associate network packets with network devices associated with a particular container. For example, you can have multiple web servers, each in a different container, which allows these web servers to bind 80 port numbers in their namespaces
Create a network space on the command line
/ var/run/netns
# ip netns add netns1
# ip netns exec netns1 ip link list
# ip netns delete netns1
Network device (physical or virtual interfaces, bridges)
Virtual network devices
Virtual ethernet or veth
Created, the lo loopback device
# ip netns exec netns1 ping 127.0.0.1
Connect: Network is unreachable
# ip netns exec netns1 ip link set dev lo up
# ip netns exec netns1 ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56 (84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.051 ms
# ip link add veth0 type veth peer name veth2
# ip link set veth2 netns netns1
# ip netns exec netns1 ifconfig veth2 10.1.1.1/24 up
# ifconfig veth0 10.1.1.2/24 up
# ping 10.1.1.1
# ip netns exec netns1 ping 10.1.1.2
# ip netns exec netns1 route
This is the end of "how to create linux namespaces". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.