centos 7 网络配置( 网关、dns、ip地址配置)

centos 7 网络配置( 网关、dns、ip地址配置)插图

1.配置DNS (可忽略)
vim   /etc/resolv.conf

route add default gw dev eno*
这样就把网关修改为192.168.1.1了,这种修改只是临时的,当你重新启动系统或网卡之后,还是会变回原来的网关。要想永久性修改,就要修改/etc/sysconfig/network 这个文件,这个文件的主要内容如下(你的文件中没有的项,你可以手动添加):

vim  /etc/sysconfig/network
NETWORKING=yes #表示系统是否使用网络,一般设置为yes。如果设为no,则不能使用网络。

HOSTNAME=centos #设置本机的主机名,这里设置的主机名要和/etc/hosts中设置的主机名对应

GATEWAY= #设置本机连接的网关的IP地址。

vim  /etc/sysconfig/network-scripts/ifcfg-eno*
 BOOTPROTO=static  #启用静态IP地址
 ONBOOT=yes  #开启自动启用网络连接
 IPADDR0=  #设置IP地址
 PREFIXO0=24  #设置子网掩码
 GATEWAY0=  #设置网关
 DNS1=  #设置主DNS
 DNS2=  #设置备DNS
 :wq!  #保存退出

vim /etc/hostname #编辑配置文件

www   #修改localhost.localdomain为www

vim /etc/hosts #编辑配置文件   localhost  www   #修改localhost.localdomain为www

ip link set eth0 upi          # 开启网卡
ip link set eth0 down         # 关闭网卡

service network restart




    • qhj0928

      2020.10.30 12:10

      I cannot understand

  • I am genuinely grateful to the holder of this website
    who has shared this fantastic post at at this time.

  • School Design Images English Literature Aqa Gcse Past Papers

    Look at my web site; ebook (trumponcoronavirus.blogspot.com)

  • Ann

    2020.7.20 04:07

    Thanks for your personal marvelous posting! I truly enjoyed reading it, you could be
    a great author. I will make certain to bookmark your blog and will come back down the road.

    I want to encourage you to continue your great job, have a nice morning!

  • Quickbooks premier

    2020.7.5 01:07

    Good day! I could have sworn I’ve visited this blog before but after going through some of the articles I realized it’s new to me. Anyhow, I’m certainly pleased I discovered it and I’ll be bookmarking it and checking back often!

  • g

    2020.6.17 16:06

    You actually make it appear really easy along with your
    presentation but I to find this topic to be actually something which I feel I’d by no means understand.

    It kind of feels too complicated and extremely large for me.
    I am taking a look ahead in your next publish, I will
    try to get the hold of it!

  • g

    2020.6.17 03:06

    I am sure this piece of writing has touched all the internet viewers, its really really good post on building up new webpage.

  • g

    2020.6.16 09:06

    Hi, Neat post. There is an issue along with your website in web explorer,
    may test this? IE still is the marketplace leader and a huge section of folks will leave out your great writing
    because of this problem.

  • g

    2020.6.15 22:06

    I am curious to find out what blog system you have been working with?
    I’m having some minor security issues with my latest site and I would
    like to find something more secure. Do you have any recommendations?

  • Howdy are using WordPress for your blog platform? I’m new to the
    blog world but I’m trying to get started and set up
    my own. Do you require any coding knowledge to make
    your own blog? Any help would be really appreciated!

  • Fleck 5600SXT System

    2020.4.4 05:04

    The other day, while I was at work, my sister
    stole my iPad and tested to see if it can survive
    a 40 foot drop, just so she can be a youtube sensation. My apple ipad is now destroyed and she has 83 views.
    I know this is completely off topic but I had to share it with