当前位置:首页 > 系统 > CentOS7 network namespaces

CentOS7 network namespaces

系统3年前 (2020-12-22)

CentOS7 network namespaces

通过创建2个网络命名空间和2个虚拟网卡,使2个虚拟网卡互通

+----------------------------------------------------------------+
|                                                                |
|       +------------------------------------------------+       |
|       |             Newwork Protocol Stack             |       |
|       +------------------------------------------------+       |
|              ↑               ↑               ↑                 |
|..............|...............|...............|.................|
|              ↓               ↓               ↓                 |
|        +----------+    +-----------+   +-----------+           |
|        |   eth0   |    |   veth0   |   |   veth1   |           |
|        +----------+    +-----------+   +-----------+           |
|192.168.1.2  ↑                ↑               ↑                 |
|              |               +---------------+                 |
|              |            10.0.0.100     10.0.0.200            |
+--------------|-------------------------------------------------+
               ↓
         Physical Network


创建2个虚拟网络空间

ip netns add ns0
ip netns add ns1
ll /var/run/netns

CentOS7 network namespaces


创建2个虚拟网卡

ip link add veth0 type veth peer name veth1
ip link set veth0 netns ns0
ip link set veth1 netns ns1
ip netns exec ns0 ifconfig -a

CentOS7 network namespaces


添加ip地址

ip netns exec ns0 ifconfig veth0 10.0.0.100/24 up
ip netns exec ns1 ifconfig veth1 10.0.0.200/24 up
ip netns exec ns1 ifconfig -a

CentOS7 network namespaces


测试

ip netns exec ns0 ping 10.0.0.200 -c 10

CentOS7 network namespaces

本站所有文章均可随意转载,转载时请保留原文链接及作者。

本文链接:https://www.vos.cn/os/469.html

相关文章

VTL6900实验 Oracle备份方案

VTL6900实验 Oracle备份方案

【实验需求】环境中有一台已安装好的Oracle服务器,Oracle数据库监听已打开,且工作在归档模式。服务器中已创建一个数据库实例oltp,oltp的当前数据量约为1G。预计:周一~周六,访问量较大,...

台式机使用u盘安装chromeos第三方cloudready

台式机使用u盘安装chromeos第三方cloudready

 首先准备好一个8G或者16G的u盘https://www.neverware.com/freedownload下载32位或者64位的系统将下载好的文件解压出bin格式的文件本地需要安装ch...

解决SecureCRT连接linux无配色

解决SecureCRT连接linux无配色

SecureCRT默认ssh连接linux是无配色的,看起来很难受左侧选中需要调整的会话名称->右键->Properties ->Session Options -> Term...

CentOS7 搭建LNMP

CentOS7 搭建LNMP

使用CentOS 1708,其实就是RHEL 7.4,使用YUM搭建LNMP环境(Linux、Nginx、MariaDB、PHP),全部使用新版组件,比如Nginx 1.12.2、MariaDB 10...

CentOS7 iSCSI配置

CentOS7 iSCSI配置

先用5块磁盘组成RAID 6,其中4盘做RAID,1盘做热备,并在组建的阵列提供iSCSI服务yum install mdadm mdadm -Cv /dev...

Redhat 6.5网卡聚合绑定

Redhat 6.5网卡聚合绑定

linux下网卡bonding配置是通过多张网卡绑定为一个逻辑网卡,实现本地网卡的冗余,带宽扩容和负载均衡,在生产场景中是一种常用的技术,常用聚合模式为0,1,60(balance-rr)轮循(RR)...