Networking Flashcards
Command: List and Modify Interfaces
ip link
- OR -
ip -n <NAMESPACE> link</NAMESPACE>
Command: List IP Addresses on an Interface
ip addr
Command: Set IP Address on an Interface
ip addr add <CIDR> dev eth0
/etc/network/interfaces</CIDR>
Command: View Routing Table
ip route
Command: Add entries into the Route Table
ip route add (CIDR) via (GATEWAYIP)
Location: Where IP Forwarding is set
/proc/sys/net/ipv4/ip_forward
Location: Where DNS Name Server is set
/etc/resolv.conf
Location: Where DNS Order is set
hosts: files dns
Command: List Network Namespaces
ip netns
Command: Add Network Namespace
ip netns add <NAMESPACE></NAMESPACE>
Command: Add a Virtual Interface between Namespaces
1) ip link add <VIRTINTERFACENAME1> type veth peer name <VIRTINTERFACENAME2>
2) ip link set <VIRTINTERFACENAME1> netns <NAMESPACE1>
3) ip link set <VIRTINTERFACENAME2> netns <NAMESPACE2>
4) ip -n <NAMESPACE1> addr add <IPADDR1> dev <VIRTINTERFACENAME1>
5) ip -n <NAMESPACE2> addr add <IPADDR2> dev <VIRTINTERFACENAME2>
6) ip -n <NAMESPACE1> link set <VIRTINTERFACENAME1> up
7) ip -n <NAMESPACE2> link set <VIRTINTERFACENAME2> up</VIRTINTERFACENAME2></NAMESPACE2></VIRTINTERFACENAME1></NAMESPACE1></VIRTINTERFACENAME2></IPADDR2></NAMESPACE2></VIRTINTERFACENAME1></IPADDR1></NAMESPACE1></NAMESPACE2></VIRTINTERFACENAME2></NAMESPACE1></VIRTINTERFACENAME1></VIRTINTERFACENAME2></VIRTINTERFACENAME1>
Command: Execute on Namespace
ip -n <NAMESPACE> link ping <IPADDR></IPADDR></NAMESPACE>
Command: Create a NAT Gateway
iptables -t nat -A POSTROUTING -s <CIDR> -j MASQUERADE</CIDR>
Command: Port Forwarding Rule
iptables -t nat -A PREROUTING –dport 80 –to-destination <IPADDR:PORT> -j DNAT</IPADDR:PORT>
Command: Display IP Address to MAC Address Mapping
arp