zoukankan      html  css  js  c++  java
  • CentOS 7: 配置Network

    Command Mode

    Step 1 » Network interface config files are located in /etc/sysconfig/network-scripts/ directory. Open ifcfg-enp0s17 file ( For interface enp0s17 ) and you can see the content like below.
    [root@krizna ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s17
    TYPE=Ethernet
    BOOTPROTO=none
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_FAILURE_FATAL=no
    NAME=enp0s17
    UUID=7f1aff2d-b154-4436-9497-e3a4dedddcef
    ONBOOT=no
    HWADDR=00:0C:29:A1:B5:D6
    PEERDNS=yes
    PEERROUTES=yes
    IPV6_PEERDNS=yes
    IPV6_PEERROUTES=yes

    » DHCP configuration

    Step 2 » For DHCP
    Find the below lines in config File.
    BOOTPROTO=none
    ONBOOT=no
    and replace with
    BOOTPROTO=dhcp
    ONBOOT=yes
    Now Restart network service by typing below command.
    systemctl restart networkNow your server will get IP Address from DHCP

    » Static configuration

    Step 3 » For Static IP.
    Find the below lines in config File.
    BOOTPROTO=none
    ONBOOT=no
    and replace with
    BOOTPROTO=static
    ONBOOT=yes
    And add the below lines at the end of the file.
    IPADDR=172.27.0.32
    NETMASK=255.255.255.0
    GATEWAY=172.27.0.1
    DNS1=172.27.0.5
    File will look like below after changes.
    TYPE=Ethernet
    BOOTPROTO=static
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_FAILURE_FATAL=no
    NAME=enp0s17
    UUID=f0c5b37d-299a-43cb-b74b-618bb252d129
    ONBOOT=yes
    HWADDR=00:0C:29:A1:B5:CC
    IPV6_PEERDNS=yes
    IPV6_PEERROUTES=yes
    IPADDR=192.168.1.10
    NETMASK=255.255.255.0
    GATEWAY=192.168.1.1
    DNS1=192.168.1.5

    Now Restart network service by typing below command.
    systemctl restart networkNow Interface will have static IP.
    Additionally you can use /etc/sysconfig/network file for hostname and DNS .
    HOSTNAME=server.krizna.com
    DNS1=192.168.1.5
    DNS2=8.8.8.8
    SEARCH=krizna.com

    Have a nice day

  • 相关阅读:
    脚本编辑器的写法
    图集优化
    数组与链表的区别
    第四课 vi编辑器使用
    第三课下 Linux termina命令行常用快捷键
    第三课上 Linux命令入门
    01.Volatile相关知识
    第二课 Ubuntu环境搭建和图形界面操作
    第一课 不要用老方法学习单片机和ARM
    第八讲 IPC之信号量Semaphore
  • 原文地址:https://www.cnblogs.com/ilovewindy/p/4532940.html
Copyright © 2011-2022 走看看