centos7 修改网卡名为eth0及基本优化

1 Centos7 修改网卡名及修改静态ip

[root@localhost ~]# cd /etc/sysconfig/network-scripts/

[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-ens33.bak

[root@localhost network-scripts]# cp ifcfg-ens33.bak ifcfg-eth0

[root@localhost 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变量来实现的。

[root@localhost ~]# 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"

 

[root@localhost ~]# 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



3 linux 普通用户切换成root免密码

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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章