centos7 修改网卡名为eth0及基本优化
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7 修改网卡名为eth0及基本优化相关的知识,希望对你有一定的参考价值。
1 Centos7 修改网卡名及修改静态ip
[[email protected] ~]# cd /etc/sysconfig/network-scripts/
[[email protected] network-scripts]# cp ifcfg-ens33 ifcfg-ens33.bak
[[email protected] network-scripts]# cp ifcfg-ens33.bak ifcfg-eth0
[[email protected] network-scripts]# vim ifcfg-eth0
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="eth0"
UUID="67f8ea1b-568d-4762-9558-20337f2d2bdd"
DEVICE="eth0"
IPADDR=192.168.4.4
NETMASK=255.255.255.0
GATEWAY=192.168.4.1
ONBOOT="yes"
禁用该可预测命名规则。对于这一点,你可以在启动时传递“net.ifnames=0 biosdevname=0 ”的内核参数。这是通过编辑/etc/default/grub并加入“net.ifnames=0 biosdevname=0 ”到GRUBCMDLINELINUX变量来实现的。
[[email protected] ~]# vim /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root "net.ifnames=0 biosdevname=0" rd.lvm.lv=centos/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
[[email protected] ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
重启机器验证即可
2 优化ssh
sed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_config
sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config
systemctl restart sshd.service
vim /etc/pam.d/su
...
4 #auth sufficient pam_wheel.so trust use_uid
...
将第四行配置文件# 去掉,将普通用户加入wheel组
usermod -G wheel 用户
4 基础依赖安装
yum -y install gcc gcc-c++ make autoconf libtool-ltdl-devel gd-devel freetype-devel libxml2-devel libjpeg-devel libpng-devel openssl-devel curl-devel bison patch unzip ncurses-devel sudo bzip2 mlocate flex lrzsz sysstat lsof setuptool system-config-network-tui system-config-firewall-tui ntp libaio-devel wget nmap finger elinks net-tools tree vim firefox
5 防火墙seLinux
systemctl disable firewalld.service
systemctl stop firewalld.service
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
setenforce 0
echo "nameserver 202.106.0.20" >> /etc/resolv.conf
echo "nameserver 114.114.114.114" >> /etc/resolv.conf
6 安装阿里源及epel源
wget http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all && yum makecache
yum -y install epel-release
7 优化history
vim /etc/profile
...
USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
export HISTTIMEFORMAT="[%F %T][`whoami`][${USER_IP}] "
source /etc/profile
以上是关于centos7 修改网卡名为eth0及基本优化的主要内容,如果未能解决你的问题,请参考以下文章