iproute2 inerfaces, bridges, forwarding, iptables classification, NAT, filtering,
tc queueing discipline, ipvsadm load balancing
gre tunnel an Ethernet device, vxlan and a bridge
ip link add name mybridge type bridge
ip link set mybridge up
ip link set eth1 master mybridge
ip link set eth2 master mybridge
ip link set eth3 master mybridge
ip link add link eth0 name eth0.2 type vlan id 2
ip link add name gen0 type geneve id 55 remote 1.2.3.4
ip route add 11.11.0.0/16 dev eth3
via is an option within the ip route add. Via indicates that there is a hop in between at the IP
layer. The next hop won't be the destination. For example in p route add 11.11.0.0/16 via 192.168.2.1 dev eth3 vs ip route add 11.11.0.0/16 dev eth3.
Linux will ARP for the destination in the packet (without via) or ARP for the next hop (with via)
ip neigh show can be used to look at the ARP table. Example:
jack@grapefruit:~$ ip neigh show
192.168.0.214 dev wlp4s0 lladdr e4:5f:01:2e:37:bd REACHABLE
192.168.0.167 dev wlp4s0 lladdr 00:11:32:af:99:21 STALE
192.168.0.1 dev wlp4s0 lladdr e4:38:83:3c:62:8a REACHABLE
protocol bgp uplink1 {
description "My BGP uplink";
local 198.51.100.1 as 65000;
neighbor 192.51.100.10 as 64496;
hold time 90;
password "secret";
# You can then add a filter to ignore certain things either as an import/export
ipv4 {
import filter rt_import;
export where source ~ [ RTS_STATIC, RTS_BGP ];
}
}
birdc show route all will show the current rounting table in the bird routing daemon.
iptables is part of the netfilter framework that can configure the
Linux kernel's filtering framework. The default table is filter but it can be configured with -t
iptables is a tool to set those rules!
iptables -t nat -A PREROUTING -d 111.111.0.1 -p tcp --dport 1000 -j DNAT --to-destination 10.10.0.2
This example command sets ingress traffic with destination 111.111.0.1 to new destination
10.10.0.2
modprobe ipvs to load ipvs.
ipvsadm -A -t 207.175.44.110:80 -s rr adds a TCP service at IP address 207.175.44.110 port 80 and
will select a backend server in a round robin manner.
tc = linux traffic control utility. Used for QoS setup and more. Key constructs:
qdisc, class, filter.
tc qdisc [add | delete | replace] dev DEV \ [parent qdisc=id | root] [handle
qdisc-id] qdisc [qdisc specific parameters]
tc qdisc add dev eth0 root handle 1: tbf rate 1mbit burst 32kbit latency 400ms uses
token bucket filter qdisc as the queuing discipline.
nsproxy is a struct in that task/process struct that has a struct for namespaces and one in particular called
net. This has all the variables for networking! Things like netns_ipv4 for ipv4 rules and config.
Things like FIB (forward information base = forwarding table). Each namespace has its own set of tables.
ip netns is the Linux utility for modifying network namespaces.Processes inherit their namespaces from their parent
(up to the root process).
ip netns add NAME = create a network namespace. ip netns ls to list. Need to run as sudo.
ip link add _p1-name_ type veth peer name _p2-name_ to add a veth.
ethtool can be used to find the peer of a veth network interface combined with ip link Could
also generate a specific packet with scapy and inspect the other sides with tshark
ip link set _p2-name_ netns _p2-namespace_
ip netns add nsDemo1 ip netns add nsDemo2 ip link add vethY type veth peer name vethZ ip link set vethZ netns nsDemo1 ip link set vethY netns nsDemo2
ip netns exec _cmd_ Can then use regular ip commands!
ip netns exec via ip -n
ip netns ls from
resolving a new network created inside a container.
docker0 is the default bridge that each veth device in the root namespace is connected to in Docker.
sudo touch /var/run/netns/$container_name
pid=$(sudo docker inspect -f '{{.State.Pid}}' $container_name)
echo $pid
sudo mount -o bind /proc/$pid/ns/net /var/run/netns/$container_name
docker network create and docker network connect _network_ _container_
kube-proxy Makes sure client can connect to the services you define, load balanced when needed.
Runs on every node, but it's not in the path of traffic (not an actual proxy i.e. does not
actually process network traffic). It just interfaces to iptables/ipvs.
kubectl describe pod podname, kubectl describe node nodename,
cat /path/to/network-plugin-log, and journalctl -u kubelet