用 shell 获取本机的网卡名称
# 用 shell 获取本机的网卡名称
ls /sys/class/net
# 或者
ifconfig | grep "Link" | awk '{print $1}'
# 当前网卡的IP地址
ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
# 用 shell 获取当前IP的C类地址 sed 's/\.[0-9]*$/\.0\/24/' /tmp/ip.txt
# 用 shell 获取当前IP的B类地址 sed 's/\.[0-9]\.[0-9]*$/\.0\.0\/16/' /tmp/ip.txt
# 举例
IP=107.172.3.211
echo $IP>/tmp/ip.txt
IP=`sed 's/\.[0-9]\.[0-9]*$/\.0\.0\/16/' /tmp/ip.txt`
echo $IP
CentOS 7 退回 iptables 的办法
CentOS 7 退回 iptables 的办法:
首先,停止并取消 firewalld 的启动
systemctl stop firewalld
systemctl mask firewalld
然后,安装 iptables-services
yum install iptables-services
保存 iptables 规则
service iptables save
重启 iptables
service iptables restart