用 shell 獲取本機的網卡名稱

用 shell 獲取本機的網卡名稱
java


# 用 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
相關文章
相關標籤/搜索