Linux ip --Show/manipulate routing, network devices, interface and tunnels
- Private IP addresses are the ones your WiFi box (and company intranet) provide. They are in the range of 10.x.x.x, 172.16.x.x-172.31.x.x, and 192.168.x.x, where x=0 to 255.
基本命令为“ip”,有些用户使用它来代替废弃的 ifconfig,route,netstat.
ifconfig --> ip addr or just ip a ifconfig <interface> up/down --> ip link set dev <interface> up/down ifconfig <interface> <ip> netmask <netmask> --> ip addr add <ip>/<masklen> dev <interface> netstat -rn --> ip route or just ip r route add -net <net> netmask <netmask> gw <gateway> --> ip r add <net>/<netmasklen> via <gateway>
Creating and Listing network namespace : ip netns
The default namespace is not included in ‘ip netns list’ output.
<BROADCAST,MULTICAST,UP,LOWER_UP>, its meaning, please check 'netdevice';
LOWER_UP
is a physical layer link flag (the layer below the network layer, whereIP
is generally located).LOWER_UP
indicates that an Ethernet cable was plugged in and that the device is connected to the network.LOWER_UP
differs fromUP
, which additionally requires the network interface to be enabled.Managing the ARP Table: ip neigh (link layer neighbour control, mostly ARP)
- Show local ARP cache: ip neigh show
- flush (delete) all dynamic ARP entries : ip neigh flush dev ens32
- add a static ARP entry for the specified IP and MAC address combination, available via eth0 – potentially dangerous! : ip neigh add 1.1.1.13 lladdr AA:BB:CC:DD:EE:FF dev eth0
- delete the static or dynamic ARP entry for the specified IP address – potentially dangerous! : ip n del 1.1.1.13
When a Client is attempting to speak to a host in a foreign network, the Client will issue an ARP request for the Default Gateway’s IP address (Default gateway --- Nearest Router); ARP’s role is to help the client create the proper L2 header, based on the L3 header, in order to get the packet from one hop to the next.
- When a Client is speaking to a host in the _same _network, it will ARP for the IP address of the host When a Client is speaking to a host in a _different _network, it will ARP for the IP address of the Default Gateway
MAC Address Tables (Used by Switch) is a mapping of mac address and switch port
IP masquerading : IP伪装
网络路由(ip route)
- route traffic via 192.168.2.254 gateway for 192.168.2.0/24 network --- 通过192.168.2.254网关为192.168.2.0/24网络路由流量
- A static route is nothing but a way of specifying traffic that must not go through the default gateway. --- 静态路由只不过是一种指定流量不能通过默认网关的的方法。
ff