ubuntu 网络配置 ip dns

来源:互联网 发布:prisma 知乎 编辑:程序博客网 时间:2024/05/17 21:45


修改网络配置文件

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface 网络回环地址 默认配置
auto lo
iface lo inet loopback

# The primary network interface
auto eth0  #系统启动自动加载
iface eth0 inet static #inet标识ipv4   inet6 标识ipv6  statci静态地址  dhcp 动态地址
        address 192.168.1.101  #静态ip地址
        netmask 255.255.255.0 # 子网掩码
        network 192.168.1.0 
        broadcast 192.168.1.255  #子网广播地址
        gateway 192.168.1.1 #网关
        # dns-* options are implemented by the resolvconf package, if installed  # resolvconf package会把dns写入/etc/resolv.conf
        dns-nameservers 192.168.1.100 #DNS
        dns-nameservers 202.*.*.*  # 备用DNS

修改dns配置文件 /etc/resolv.conf,如上述resolvconf package会把dns 写入/etc/resolv.conf ,如没有相关包自己写入

       nameserver 10.10.2.8
       nameservers 202.*.*.*  # 备用DNS

重启网络 

        sudo ifdown eth0 #禁用网卡
        sudo ifup eth0 #启用网卡

        sudo service networking restart #重启网络服务
        sudo reboot #重启计算机

临时配置网络 

用下面命令临时设置网络重启服务或者计算机都会清空设置

sudo ifconfig eth0 192.168.1.101 netmask 255.255.255.0;route add default gw 192.168.1.1;echo nameserver 192.168.1.100 >/etc/resolv.conf


网络命令

ipconfig  (window) ifconfig (linux) 查看ip配置

arp  令用于查询本机ARP缓存中IP地址-->MAC地址的对应关系、添加或删除静态对应关系等

ping 检查网络是否通



ubuntu 网络不稳定 可能原因IP冲突













0 0
原创粉丝点击