ifdown interface 关闭指定网卡的IP地址
ifup interface 开启指定网卡的IP地址
ifconfig interface up 激活指定网卡
ifconfig interface down 禁用指定网卡
netstat
-t 显示tcp
-u 显示udp
-w 显示socket
-n 以数字方式显示IP及端口,不在通过dns反解
-l 显示监听
-a 显示所有状态
-e 显示扩展
-r 显示路由表
-p 显示进程pid及进程名
-i 显示所有网络接口的信息
-Iinterface 显示指定网络接口的信息,注意I与接口名之间无空格 等于同ifconfig -s interface
常用组合
-tulnp
-rn 打印路由表 等于同route -n
ss
-t 显示tcp
-u 显示udp
-w 显示socket
-n 以数字方式显示IP及端口,不在通过dns反解
-l 显示监听 默认显示tcp
-a 显示所有状态
-e 显示扩展
-p 显示进程pid及进程名
-tulnpa
-tan
-uan
ip
ip link(ip l)
ip link show [eth2]
链路层激活网卡
ip link set eth2 up 或 ifconfig eth2 up
链路层禁用网卡
ip link set eth2 down 或 ifconfig eth2 down
ip addr(ip a)
ip addr show [eth2]
ip addr add 1.1.1.1/24 dev eth0
ip addr add 2.2.2.2/24 dev eth0 scope host/link/global
ip addr add 3.3.3.3/24 dev eth0 label eth0:lan1
ip addr del 1.1.1.1/24 dev eth0
ip addr flush dev eth0
ip route
ip route add 192.168.153.200 via 192.168.153.128
ip route add 8.8.8.0/24 via 192.168.153.128
ip route add default via 192.168.153.128
ip route del default
ip r d 192.168.153.200
ip r d default
ip r f dev eth0 删除关于eth0的所有路由
Centos7当中的网卡配置
nmcli
nmcli device show eth0 查看网卡设备信息
nmcli device status
nmcli connection 查看所有配置文件信息
nmcli connection modify eth0 connection.id config-eth0-1
nmcli connection show config-eth0-1 查看指定网卡配置文件"config-eth0-1"的信息
nmcli connection add con-name config-eth0-2 默认新建的配置文件,ipv4.method 为dhcp
nmcli connection up config-eth0-2
nmcli connection down config-eth0-2
nmcli connection modify config-eth0-2 connection.autoconnect yes
nmcli connection modify config-eth0-2 ipv4.method manual ipv4.addresses 1.1.1.1/24 [ipv4.gateway 1.1.1.254 ipv4.dns 114.114.114.114]
nmcli connection modify config-eth0-2 +ipv4.address 2.2.2.2/24
nmcli connection del config-eth0-2
转载于:https://blog.51cto.com/13560258/2084746