包含标签 SDN articles

SNAT和DNAT

参考

SNAT

In Source Network Address Translation (SNAT), the NAT router modifies the IP address of the sender in IP packets. SNAT is commonly used to enable hosts with private addresses to communicate with servers on the public Internet.

RFC 1918 reserves the following three subnets as private addresses:

10.0.0.0/8

172.16.0.0/12

192.168.0.0/16

DNAT

In Destination Network Address Translation (DNAT), the NAT router modifies the IP address of the destination in IP packet headers.

OpenStack uses DNAT to route packets from instances to the OpenStack metadata service. Applications running inside of instances access the OpenStack metadata service by making HTTP GET requests to a web server with IP address 169.254.169.254. In an OpenStack deployment, there is no host with this IP address. Instead, OpenStack uses DNAT to change the destination IP of these packets so they reach the network interface that a metadata service is listening on.

……

Continue reading

免费arp

免费(Free ARP)的作用是什么

解决方案 A:主机主动使用自己的IP地址作为目标地址发送ARP请求,此种方式称免费ARP。免费ARP有两个方面的作用:

  1. 用于检查重复的IP地址 正常情况下应当不能收到ARP回应,如果收到,则表明本网络中存在与自身IP地址重复的地址。

2.用于通告一个新的MAC地址 发送方换了块网卡,MAC地址变了,为了能够在ARP表项老化前就通告所有主机,发送方可以发送一个免费ARP。

……

Continue reading

容器化和kvm的区别

容器和KVM虚拟化是两种不同的虚拟化技术,它们各有优缺点,适用于不同的场景。

容器

容器是一种轻量级的虚拟化技术,利用操作系统层面的虚拟化实现。每个容器都运行在一个独立的命名空间中,可以看作是进程的一个集合,共享主机操作系统的内核。容器可以快速启动、停止和迁移,占用的资源比KVM虚拟机少,因此更适合部署大规模的分布式应用程序。常见的容器技术包括Docker、LXC等。 优点:

……

Continue reading

查看POD的IP地址

从外面看Pod IP地址之Kubernetes API

  1. kubectl get pod或者kubectl describe pod就可以
  2. 如果运行在容器内的进程希望获取该容器的IP,可以通过环境变量的方式来获取IP
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
spec:
  containers:
    - name: env-pod
      image: busybox
      command: ["/bin/sh", "-c","env"]
      env:
      - name: POD_IP
        valueFrom:
          fieldRef:
            fieldPath: status.podIP

从外面看Pod IP之docker命令

假设容器的ID是6e8147cd2f3d, 一般情况下可以通过以下命令查询容器的IP地址:

……

Continue reading

网卡的混杂模式

混杂模式(英语:promiscuous mode)是指一台机器的网卡能够接收所有经过它的数据流,而不论其目的地址是否是它。

一般计算机网卡都工作在非混杂模式下,此时网卡只接受来自网络端口的目的地址指向自己的数据。当网卡工作在混杂模式下时,网卡将来自接口的所有数据都捕获并交给相应的驱动程序。网卡的混杂模式一般在网络管理员分析网络数据作为网络故障诊断手段时用到,同时这个模式也被网络黑客利用来作为网络数据窃听的入口。在Linux操作系统中设置网卡混杂模式时需要管理员权限。在Windows操作系统和Linux操作系统中都有使用混杂模式的抓包工具,比如著名的开源软件Wireshark。

……

Continue reading