zoukankan      html  css  js  c++  java
  • ubuntu网络配置相关知识(转载)

    From:http://os.51cto.com/art/201003/188055.htm

    文章主要介绍Ubuntu网络配置,希望能让Linux新手学习参考。更好使用Ubuntu。更有效的学习Ubuntu的基础知识。

    1、配置eth0的IP地址,同时激活该设备:

    #ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up

    2、配置eth0别名设备eth0:1,并添加路由:

    #ifconfig eth0 192.168.1.3

    #route add –host 192.168.1.3 dev eth0:1

    3、激活设备:

    #ifconfig eth0 up

    4、禁用设备:

    #ifconfig eth0 down

    5、查看指定网络接口配置及查看所有网络接口配置:

    #ifconfig eth0     //查看eth0网络配置
    #ifconfig             //查看所有设备的网络配置

    route:可以使用route命令配置并查看内核路由表的配置情况。

    1、添加到主机的路由:

    #route add –host 192.168.1.2 dev eth0:0
    #route add –host 10.20.30.148 gw 10.20.30.40

    2、添加到网络的路由:

    #route add –net 10.20.30.40 netmask 255.255.255.248 eth0
    #route add –net 10.20.30.48 netmask 255.255.255.248 gw 10.20.30.41
    #route add –net 192.168.1.0/24 eth1

    3、添加默认网关及查看路由表:

    #route add default gw 192.168.1.1
    #route

    4、删除路由:

    #route del –host 192.168.1.2 dev eth0:0
    #route del –host 10.20.30.148 gw 10.20.30.40
    #route del –net 10.20.30.40 netmask 255.255.255.248 eth0
    #route del –net 10.20.30.48 netmask 255.255.255.248 gw 10.20.30.41
    #route del –net 192.168.1.0/24 eth1
    #route del default gw 192.168.1.1

    对于以上操作可使用下面的语句实现:

    I
    ifconfig eth0 172.16.19.71 netmask 255.255.255.0 route 0.0.0.0 gw 172.16.19.254 service network restart

    traceroute:显示数据包到达目的主机经过的路由。

    #traceroute x

    ping :测试网络的连通性。

    #ping x
    #ping –c 4 192.168.1.12

    netstat:显示网络状态信息。

     

    arp:配置并查看arp缓存。

    查看arp缓存。
    #arp
     添加一个IP地址和MAC地址的对应记录。
    #arp –s 192.168.33.15 00:60:08:27:CE:B2
    删除一个IP地址和MAC地址的对应缓存记录。
    #arp –d192.168.33.15

    Ubuntu命令行下的网络配置
    编辑 /etc/network/interface:

    auto lo
    iface lo inet loopback
    auto eth0
    如果是自动获取ip,添加
    iface eth0 inet dhcp
    如果是手动配置ip,添加
    iface eth0 inet static
    address xxx.xxx.xxx.xxx
    netmask xxx.xxx.xxx.xxx
    network xxx.xxx.xxx.xxx
    boardcast xxx.xxx.xxx.xxx
    gateway xxx.xxx.xxx.xxx
    tags:命令,网络,Ubuntu
  • 相关阅读:
    Python中的装饰器之@wraps(四)
    python中装饰器之有参装饰器(三)
    python中装饰器之叠加装饰器(二)
    python中装饰器之闭包函数(一)
    python中的命名空间
    函数的嵌套与迭代
    函数对象
    matlab学习checkbox使用
    matlab学习滚动条改变文本数值
    matlab学习GUI可调的界面窗口
  • 原文地址:https://www.cnblogs.com/xiaoerlang/p/3834132.html
Copyright © 2011-2022 走看看