分享

RedHat、CentOS设置静态IP、主机名、关闭防火墙(虚拟机VMware客户机)

 丁兆海 2015-08-06

设置静态IP、主机名

1. /etc/sysconfig/network

  [root@hadoop ~]# vi /etc/sysconfig/network

  NETWORKING=yes
  HOSTNAME=hadoop  #主机名
  GATEWAY=192.168.80.1  #网关

2. /etc/sysconfig/network-scripts/ifcfg-eth0

  [root@hadoop ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

  DEVICE="eth0"
  NETMASK="255.255.255.0"  #子网掩码
  IPADDR="192.168.80.100"  #ip地址
  BOOTPROTO="static"  #取值:none  | static | bootp | dhcp(默认值)

          #引导使用的协议:无协议 | 静态 | bootp | dhcp

  HWADDR="00:0C:29:6F:B6:BE"   #MAC地址
  NM_CONTROLLED="yes"
  ONBOOT="yes"  #取值:yes | no

      #引导是否激活设备: 是 | 否
  TYPE="Ethernet"
  UUID="27a2ebe6-e3de-4a99-92ec-bf67336928bf"
  PEERDNS="yes"

  DNS1="8.8.8.8"  #域名解析服务器(没配)

3. /etc/hosts

  [root@hadoop ~]# vi /etc/hosts

  127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
  ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6


  192.168.80.100 hadoop 绑定主机名和ip

--------- 可略过 -------

    /etc/resolv.conf

  [root@hadoop ~]# vi /etc/resolv.conf

  search hadoop

  nameserver 8.8.8.8  #DNS域名解析服务器

------------------------

4. 应用变更

  [root@hadoop ~]# ifdown eht0

  [root@hadoop ~]# ifup eht0  #这两个操作只能在本机进行,远程操作无反应

  [root@hadoop ~]# service network restart  #重启网络服务

5. 重启

  [root@hadoop ~]# reboot -h 0 或 shutdown -r 0

关闭防火墙:

  [root@hadoop ~]# service iptables status  #查看防火墙状态

  [root@hadoop ~]# service iptables stop  #关闭防火墙

  [root@hadoop ~]# chkconfig iptables off  #关闭防火墙自启动

  [root@hadoop ~]# chkconfig --list|grep iptables #查看防火墙状态 全off,即操作成功

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多