Linux 模板

SOSO
2021-09-26 / 0 评论 / 86 阅读 / 正在检测是否收录...

一、模板设置

  • 更新Linux

    yum groupinstall "Development tools" -y
    yum update -y

    1.1 删除或注释有在MAC地址信息相关文件

    /etc/sysconfig/network-scripts/ifcfg-ensxx中HWADDR和UUID, 注释或删除;
    rm -fr /etc/udev/rules.d/70-persistent-net.rules
    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
    NAME=ens33
    #UUID=6eb0a15e-d8ba-4ea0-8c3d-2bafb062a4ce   
    DEVICE=ens33
    ONBOOT=yes
    IPADDR=192.168.xxx.xxx
    NETMASK=255.255.255.0
    GATEWAY=192.168.xxx.xxx
    DNS1=223.5.5.5
    DNS2=114.114.114.114

    1.2 关闭Selinux和防火墙

  • 临时关闭selinux

    [root@localhost ~]# getenforce 
    Enforcing
    [root@localhost ~]# setenforce 0
    [root@localhost ~]# getenforce 
    Permissive
  • 永久关闭selinux

    [root@localhost]# vim /etc/selinux/config
    # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    #     enforcing - SELinux security policy is enforced.
    #     permissive - SELinux prints warnings instead of enforcing.
    #     disabled - No SELinux policy is loaded.
    SELINUX=enforcing  #修改为 disable
    # SELINUXTYPE= can take one of these three values:
    #     targeted - Targeted processes are protected,
    #     minimum - Modification of targeted policy. Only selected processes are protected.
    #     mls - Multi Level Security protection.
    SELINUXTYPE=targeted
  • 关闭防火墙

    [root@localhost ~]# systemctl list-unit-files |grep firewalld
    firewalld.service                                                enabled  
    [root@localhost ~]# systemctl stop firewalld.service
    [root@localhost ~]# systemctl disable firewalld.service
    Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
    Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
    rm -f /etc/ssh/ssh_host_*

二.修改网卡名称

2.1 重命名

mv /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-eth0

2.2 编辑vim /etc/sysconfig/network-scripts/ifcfg-eth0

TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
DEVICE=eth0
ONBOOT=yes
MTU=1450
IPADDR=xxx.xxx.xxx.xxx
NETMASK=255.255.255.0
GATEWAY=xxx.xxx.xxx.xxx
DNS1=8.8.8.8
DNS2=8.8.4.4

2.3 修改 grub 添加:net.ifnames=0 biosdevname=0

[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 net.ifnames=0 biosdevname=0 resume=UUID=0e32495a-4ac0-4c65-8125-1bc549841c52"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true

2.4 重新生成GRUB

grub2-mkconfig -o /boot/grub2/grub.cfg
0

评论 (0)

取消