• 首页 Home
  • 简介 About
  • 项目 Service
  • 案例 Cases
  • 新闻 News
  • 技术文章 本硕新闻 行业资讯

    centos系统yum remove iptables后无法登录的补救办法

    发表时间:2019-06-13  热度:

    如果你yum remove iptables,那么你遇上大麻烦了。

    首先你看看你的主机服务器商后台是否有vnc连接功能,国外linode的好像叫做lish ssh

    参考下面图片

    阿里云:01.png

     

    linode:02.png

    launch console就是

     第一步:首先,确认这个方式可以登录你的主机,恭喜有办法补救。

    运行下面命令

    #设置网卡eth0以及IP地址和子网掩码

    ifconfig eth0 你的IP地址 netmask 255.255.255.0

     

    #设置网关

    route add default gw 默认网关IP

    #默认网关IP这个看你后台有没有了,英文名字叫Default Gateway,没有就要靠猜了,比如IP地址是106.20.24.165 的网关IP可能是106.20.24.1

     

    #设置DNS

    echo "nameserver 8.8.4.4 nameserver 1.1.1.1" >> /etc/resolv.conf

    这时候,你会发现你的服务器能临时上网了,但重启后配置还会变成没网络。

    运行yum install NetworkManager

    如果发现没有找到mirrors等错误提示,就执行第二步。如果能yum install成功,直接执行第三步

    第二步,配置mirrors镜像源

    修改为163yum源-mirrors.163.com

    1、首先备份系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.repo

    [root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

     

    2、进入yum源配置文件所在的文件夹

    [root@localhost ~]# cd /etc/yum.repos.d/

     

    3、查看CentOS系统版本

    [root@localhost ~]# lsb_release -a

     

    4、下载163的yum源配置文件到上面那个文件夹内

    CentOS7

    [root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

    CentOS6

    [root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

    CentOS5

    [root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS5-Base-163.repo

     

    5、运行yum makecache生成缓存

    [root@localhost yum.repos.d]# yum makecache

     

    第三步,恢复你卸载iptables时卸载的依赖应用

    我yum install 安装下面的就可以重启使用ssh正常登录了。

    yum install NetworkManager

    yum install NetworkManager-team

    yum install NetworkManager-tui

    yum install NetworkManager-wifi

    yum install dracut-network

    yum install iproute

     

    如果你安装上面的不行,把下面的全部安装

    yum install NetworkManager

    yum install NetworkManager-team

    yum install NetworkManager-tui

    yum install NetworkManager-wifi

    yum install dhclient

    yum install dracut-network

    yum install initscripts

    yum install iproute

    yum install iptables

    yum install kbd

    yum install kexec-tools

    yum install plymouth

    然后重启看看能不能正常登陆,不行就重复上面操作,目的就是把误卸载的软件全部装回来!!!!

    如果还不行,你再找找卸载iptables时可能会顺带被卸载的组件,我只能弄到这里了。
    文章怎么样?
    相关资讯