zoukankan      html  css  js  c++  java
  • 手动配置Ubuntu Linux系列3-缺省网关和主机名

    上一篇讲到[原创]手动配置Ubuntu Linux的DHCP客户端,这里再说一下配置静态IP地址的方法。
     
    仍然是编辑 interfaces文件。
     
    $ sudo vi /etc/network/interfaces
     
    eth0配置如下:
     
    auto eth0
      address 192.168.1.123
      netmask 255.255.255.0
      gateway 192.168.1.1
     
    保存退出后,使用重启networking命令让新配置生效。
     
    $ sudo /etc/init.d/networking restart
     
    也可以通过如下命令重启网卡,让新配置生效,好处是不影响其他网络接口。
     
    $ sudo ifdown eth0
    $ sudo ifup eth0
     
    如果只是要临时改变IP地址,则不用修改interface.只用ifconfig使用即可,不过当系统重启动后,系统后会恢复interfaces中的配置上。
     
    $ sudo ifconfig eth0 192.168.1.111 netmask 255.255.255.0
     
     
    与网卡IP地址设置类似,在Ubuntu Linux中设置默认网关的方法也有两种:
    1. 在interfaces文件中设置。
     
    $ sudo vi /etc/network/interfaces
     
    在eth0的相关配置下加入gateway 192.168.1.1,如:
     
    auto eth0
    iface eth0 inet static
     address 192.168.1.123
     netmask 255.255.255.0
     gateway 192.168.1.1
     
    保存后,重新启动服务。
     
    2. 直接用命令设置:
     
    删除当前缺省网关
    $ sudo route del default gw
     
    手工配置缺省网关
    $ sudo route add default gw 192.168.1.1
     
    查看路由信息
    $ route
     
    使用本方法,修改当即生效,但重新启动后,则interfaces文件中的设置有效。
     
    3.查看主机名
    $ hosts
     
    4. 临时修改主机名
     
    $ sudo hostname testserver
     
    执行完命令后,即时生效。
     
    5.永久修改主机名
     
    $ sudo vi /etc/hostname
     
    把新的主机名写入即可。
     
    当系统重启后,会读出此文件中主机名
  • 相关阅读:
    SQLServer三种自定义函数
    IE下必须点击一下页面空白的地方才可以激活onchange事件
    1234跨年总结(2014年总结)
    半透明背景(兼容IE)
    EF Power Tools
    ASP.NET MVC报错: Multiple types were found that match the controller named
    URI、URL和URN
    SQLServer中临时表与表变量的区别分析
    C#分部方法
    __flash__removeCallback 未定义错误
  • 原文地址:https://www.cnblogs.com/fx2008/p/4164379.html
Copyright © 2011-2022 走看看