Linux network configuration management systems
- ifcfg family:
1.ifconfig: View and manage the interface and addressifconfig [INTERFACE] ifconfig -a:显示所有接口,包括inactive状态的接口; ifconfig interface [aftype] options | address ... ifconfig IFACE IP/MASK [up|down] ifconfig IFACE IP netmask NETMASK options: [-]promisc 注意:立即送往内核中的TCP/IP协议栈,并生效 管理IPv6地址: add addr/prefixlen del addr/prefixlen
2.route command: route View and manage
routing entry types:
Host route: The destination address is a single IP;
network routing: Destination IP address for the network;
default route: target any network, 0.0.0.0 / 0.0.0.0查看: route -n 添加: route add [-net|-host] target [netmask Nm] [gw GW] [[dev] If] 示例:route add -net 10.0.0.0/8 gw 192.168.10.1 dev eth1 route add -net 0.0.0.0/0.0.0.0 gw 192.168.10.1 route add default gw 192.168.10.1 删除: route del [-net|-host] target [gw Gw] [netmask Nm] [[dev] If] 示例: route del -net 10.0.0.0/8 gw 192.168.10.1 route del default
3.netstat command: Print network connections, routing tables, interface statistics, masquerade connections and multicast memberships
(1) 显示路由表:netstat -rn -r:显示内核路由表 -n:数字格式 [root@localhost /]# netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 172.20.10.1 0.0.0.0 UG 0 0 0 ens33 1.172.20.10.0 0.0.0.0 255.255.255.240 U 0 0 0 ens33
(2)显示网络连接: netstat [--tcp|-t] [--udp|-u] [--udplite|-U] [--sctp|-S] [--raw|-w] [--listening|-l] [--all|-a] [--numeric|-n] [--extend|-e[--extend|-e]] [--program|-p] -t:TCP协议的相关连接,连接均有其状态;FSM(Finate State Machine); -u:UDP相关的连接 -w:raw socket相关的连接 -l:处于监听状态的连接 -a:所有状态 -n:以数字格式显示IP和Port; -e:扩展格式 -p:显示相关的进程及PID;
(3)显示接口的统计数据: netstat {--interfaces|-I|-i} [iface] [--all|-a] [--extend|-e] [--verbose|-v] [--program|-p] [--numeric|-n] 所有接口: netstat -i 指定接口: netstat -I<IFace>