Skip to content

Instantly share code, notes, and snippets.

@feiskyer
Last active February 22, 2022 07:02
Show Gist options
  • Save feiskyer/762da4d408b22800cb210f6089090b5d to your computer and use it in GitHub Desktop.
Save feiskyer/762da4d408b22800cb210f6089090b5d to your computer and use it in GitHub Desktop.
Setup Pod egress manually
# arp_responder running on the gateway node
# sudo apt install -y python3-scapy
from __future__ import print_function
from scapy.all import *
iface = "vxlan42"
vxlan_mac = get_if_hwaddr(iface)
def handle_packet(packet):
if packet[ARP].op == ARP.who_has:
print(packet.summary())
reply = ARP(op=ARP.is_at, hwsrc=vxlan_mac, hwdst=packet.src, psrc=packet.pdst, pdst=packet.psrc)
go = Ether(dst=packet.src, src=vxlan_mac) / reply
sendp(go, iface=iface)
return
sniff(iface=iface, filter="arp",prn=handle_packet)

IP List:

  • Pod IP: 10.244.1.6
  • Gateway IP: 10.240.0.6
  • Pod's Node IP: 10.240.0.4
ip link add vxlan42 type vxlan id 42 remote 10.240.0.4 dstport 4789 dev eth0
ip link set dev vxlan42 up
ip addr add 10.252.0.5/24 dev vxlan42
ip route add default dev vxlan42 src 10.252.0.5 table 42
# Pod rule
ip rule add from all to 10.244.1.6 lookup 42
ip link add vxlan42 type vxlan id 42 remote 10.240.0.6 dstport 4789 dev eth0
ip link set dev vxlan42 up
ip addr add 10.252.0.6/24 dev vxlan42
ip route add default dev vxlan42 src 10.252.0.6 table 42
# Pod rule
ip rule add from 10.244.1.6 to all lookup 42
# Pod/Service CIDRs
ip route add 10.244.1.0/24 dev cbr0 proto kernel scope link src 10.244.1.1 table 42
ip route add 10.244.0.0/16 via 10.240.0.1 dev eth0 src 10.240.0.4 table 42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment