当前位置:网站首页>Network shell
Network shell
2022-07-28 20:32:00 【Operation and maintenance log of Panax notoginseng】
vim ipddeadd.sh
Example of multi branch network program , You can choose the script to execute , Back to main menu , And exit command
#!/bin/bash
echo -e " Please select the option to use :\n For network configuration, please press 1\n For others, please press 2\n Please enter \n Press... To exit :\c "
read num
case $num in
1)
read -p " Please enter the name of the network card :ifcfg-" nname
read -p " Use DHCP Please enter 1, Use STATIC Please enter 2 : " DHCP # From the back if Sentence judgment 1 and 2 Result
read -p " Please enter the IP Address : " IP
read -p " Please enter your gateway : " GATEWAY
read -p " Please enter the DNS Address : " DNS
read -p " Please enter your subnet mask : " NETMASK
npath="/etc/sysconfig/network-scripts/ifcfg-$nname" # Define network card path variables
function echo_network_file(){ # Use function and function name
echo "TYPE=Ethernet" > $npath
echo "BOOTPROTO="$A"" >> $npath # from if Statement judgment result definition A The content of
echo "DEFROUTE="no"" >> $npath
echo "PEERDNS="yes"" >> $npath
echo "PEERROUTES="yes"" >> $npath
echo "IPV4_FAILURE_FATAL="no"" >> $npath
echo "IPV6INIT="yes"" >> $npath
echo "IPV6_AUTOCONF="no"" >> $npath
echo "IPV6_DEFROUTE="no"" >> $npath
echo "IPV6_PEERDNS="no"" >> $npath
echo "IPV6_PEERROUTES="no"" >> $npath
echo "IPV6_FAILURE_FATAL="no"" >> $npath
echo "NAME="$nname"" >> $npath # Fill in by the entered network card name
echo "UUID=$(cat /sys/class/dmi/id/product_uuid)" >> $npath # extract uuid Fill in the contents of the document
echo "DEVICE="$nname"" >> $npath # Fill in by the entered network card name
echo "ONBOOT="yes"" >> $npath
echo "IPADDR="$IP"" >> $npath # write in IP Address
echo "GATEWAY="$GATEWAY"" >> $npath # Write the gateway address
echo "NETMASK="$NETMASK"" >> $npath # Write subnet mask
echo "DNS="$DNS"" >> $npath # write in DNS Address
}
if [ "$DHCP" = 1 ];then #if Statement judgment equals 1 Then use DHCP, Others use static ip
A="dhcp"
else
A="static"
fi
echo_network_file # End of function
echo "nameserver "$DNS"" >>/etc/resolv.conf # hold DNS Write data to the domain name resolution configuration
systemctl restart network # Restart NIC
echo " Set up the success "
;;
2)
echo "000"
./case.sh
;;
3)
exit
;;
esac
chmod +x ipaddradd.sh
Using examples :


g-HLLJ0u1x-1656487532255)]
[ Outside the chain picture transfer in …(img-LRfd3UJ6-1656487532258)]
边栏推荐
- Torch. NN. Linear() function
- Raspberry pie 4B deploy yolov5 Lite using ncnn
- [task03: complex query methods - views, subqueries, functions, etc.]
- Gru neural network
- Data mining (data preprocessing) -- Notes
- Multi-Modal Knowledge Graph Construction and Application: A Survey
- Raspberry Pie 3 connected to WiFi
- [link url]
- [C language] comprehensively analyze the pointer and sort out the pointer knowledge points
- Wust-ctf2021-re school match WP
猜你喜欢

Durham High Lord (classic DP)

Leetcode-297 serialization and deserialization of binary tree
![[detailed use of doccano data annotation]](/img/40/c18cf8d5519328d707ed89fccb70ee.png)
[detailed use of doccano data annotation]

Simple example of C language 1

七种轮询介绍(后附实践链接)

[dynamic link library (DLL) initialization example program failed "problem]
![Teach you how to draw a map with ArcGIS [thermal map]](/img/16/993da4678667884a98e1d82db37d69.png)
Teach you how to draw a map with ArcGIS [thermal map]

Who cares about the safety of the battery when it ignites in a collision? SAIC GM has something to say

C language - data storage

Anaconda creation environment
随机推荐
Durham High Lord (classic DP)
Quick sort template
关于链接到其他页面的标题
C语言数据 3(1)
C语言数据 3(2)
弹出模态框
进制及数的表示 2
Power Bi 2021 calendar DAX code
Linxu [basic instructions]
WFST decoding process
local/chain/run_ tdnn.sh:
Read JSON configuration file to realize data-driven testing
Simple use of robobrowser
How to automatically store email attachments in SharePoint
GRU神经网络
Multi-Modal Knowledge Graph Construction and Application: A Survey
Raspberry connects EC20 for PPP dialing
[link url]
Raspberrypico serial communication
Usage Summary of thymeleaf