
#!/bin/bash
################################变量定义################################
nameDevice=eth0
ipAdddress=1921684110
prefix=2552552550
netMask=2552552550
gateway=19216841
dns1=8888
dns2=19216840
################################函数模块################################
##设置NetworkManager服务
function SetNetworkManagerDisable(){
systemctl stop NetworkManager && systemctl disable NetworkManager && echo "NetworkManager is stop and disable" && return 0 || return 1
}
##设置NetworkManager服务
function SetNetworkEnable(){
systemctl restart network && systemctl enable network && echo "network is start and enable" && return 0 || return 1
}
##查看服务器第一个网卡名称
function FindFirstNICName(){
ifconfig|head -n 1|cut -d \: -f 1 && [ $ == 0 ] && nameDevice=`ifconfig|head -n 1|cut -d \: -f 1` && return 0 || return 1
}
##设置服务器网卡IP地址
function SetNICFile(){
cat > /etc/sysconfig/network-scripts/ifcfg-$nameDevice <<EOF
TYPE="Ethernet"
BOOTPROTO="none"
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=$nameDevice
DEVICE=$nameDevice
ONBOOT=yes
IPADDR=$ipAdddress
PREFIX=$prefix
NETMASK=$netMask
GATEWAY=$gateway
DNS1=$dns1
DNS2=$dns2
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_PRIVACY=no
EOF
}
##消除变量
function UnsetVariate(){
unset nameDevice
unset ipAdddress
unset prefix
unset netMask
unset gateway
unset dns1
unset dns2
}
################################程序流程################################
##设置网络服务为network
FindFirstNICName
SetNICFile
SetNetworkEnable
SetNetworkManagerDisable
UnsetVariate
#!/bin/bash
find_ip=$(sed -nr 's/eth0ip="()"/\1/p' ipxml)
echo $find_ip
你举的例子,在你的服务器上已经无法获知了
所以黑客都是要先侵入一些“肉鸡”,以肉鸡为跳板,再发起进攻,让人难以追踪
要知道谁登录A,必须要到A上查
如果是C登录B再登录A,那你就要一个个去查
以上就是关于Linux shell脚本编程——IP地址设置全部的内容,包括:Linux shell脚本编程——IP地址设置、shell 获取xml中ip并赋值、linux shell 获取登录者的IP等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)