一.网卡名称
1.安装前更改
系统安装时按Tab键,添加内核参数:net.ifnames=0 biosdevname=0
2.安装后更改
- 修改网卡配置文件中的 DEVICE= 参数的关于 eth0
- 网卡配置文件名称改为 ifcfg-eth0
- 编辑 /etc/default/grub 配置文件,在 GRUB_CMDLINE_LINUX 这个参数后面加入 net.ifnames=0 biosdevname=0
- 用 grub2-mkconfig 命令重新生成GRUB配置并更新内核
- 重启
#!/bin/bash
devname=`ifconfig | grep UP | cut -d":" -f1 | grep -v lo`
sed -i "s/DEVICE=$devname/DEVICE=eth0/" /etc/sysconfig/network-scripts/ifcfg-$devname
sed -i "s/NAME=$devname/NAME=eth0/" /etc/sysconfig/network-scripts/ifcfg-$devname
mv /etc/sysconfig/network-scripts/ifcfg-$devname /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i "/GRUB_CMDLINE_LINUX/d" /etc/default/grub
echo "GRUB_CMDLINE_LINUX=\"crashkernel=auto spectre_v2=retpoline rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet biosdevname=0 net.ifnames=0 \" " >>/etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot
二.开机项
常用保留以下启动项
ssh | ssh |
crond | 定时任务 |
sysstat | 系统性能软件包 |
rsyslog | 日志 |
NetworkManager | 网络管理器 |
irqbalace | 系统性能均衡负载 |
systemctl list-unit-files | grep enable | egrep -v "sshd.service|crond.service|sysstat|rsyslog|NetworkManager.service|irqbalance.service " | awk '{print "systemctl disable",$1}' | bash
三.常用基础软件包
yum install psmic net-tools bash-completion vim-enhanced -y
yum install tree nmap dos2unix irzsz nc lsof wget tcpdump htop iftop iotop sysstat nethogs -y
四.SSH优化
/etc/ssh/sshd_config
17 #Port 22
19 #ListenAddress 0.0.0.0 //监听地址
38 #PermitRootLogin yes //是否允许ROOT登陆
64 #PermitEmptyPasswords no //是否允许空密码
五.银河麒麟改阿里源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sed -i 's/$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo
六.常用网络监控工具
iptraf,vnstat,nload等
iptraf
yum install -y iptraf nload
--------------------------------------------------------------------------
vnstat
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum install -y vnstat
vnstat -u -i eth0
service vnstat start
chkconfig vnstat on