zoukankan      html  css  js  c++  java
  • Ubuntu/Linux网络配置常用命令

    配置ip

    
    
    
    
    打开配置文件

    sudo vim /etc/network/interfaces
    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).
    
    source /etc/network/interfaces.d/*
    
    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    # The primary network interface
    #auto enp0s3
    #iface enp0s3 inet dhcp
    
    auto enp0s3
    iface enp0s3 inet static
    address 192.168.1.122
    netmask 255.255.255.0
    gateway 192.168.1.1

    重启网络

    sudo /etc/init.d/networking restart

    关闭防火墙(详情:https://www.cnblogs.com/kluan/p/5993767.html)

    sudo ufw disable 

    查看防火墙的状态:(状态显示是“inactive”关闭状态。)如果ping不通大多是防火墙的问题

    sudo ufw status

    修改dns /etc/resolvconf/resolv.conf.d/base里面是空的添加

    nameserver 你的DNS1
    
    nameserver 你的DNS2

    修改DNS楼主亲测 vim /etc/resolv.conf(阿里的DNS)

    nameserver 223.5.5.5
    nameserver 223.6.6.6

    重启网络

    sudo /etc/init.d/networking restart
    //14.01版本
    sudo ifconfig eth0 down sudo ifconfig eth0 up

    默认重启命令行模式

    vim  /etc/default/grub
    GRUB_CMDLINE_LINUX_DEFAULT=""改GRUB_CMDLINE_LINUX_DEFAULT="test"
    sudo update-grub
    

    查看网卡名

    ls /proc/sys/net/ipv4/conf

    刷新ip

    ip addr flush dev

    修改网卡名称

    http://blog.csdn.net/wenwenxiong/article/details/52937539

    http://blog.csdn.net/wy_97/article/details/78294562

    温馨提示:

    1.虚拟主机和主机之间ip不通,怎么办?

    答:绝大多数都是防火墙的问题

    2.如果虚拟主机和主机之间可以ping通, 但是不能上网怎么办?

    答:肯定是DNS配置问题.

  • 相关阅读:
    企业级应用TOMCAT
    HTTP服务及状态码
    Zabbix服务网页报错汇总
    spring aop 嵌套方法注解不生效
    oracle数据库密码修改和解锁
    redis安装
    docker简介
    ffmpeg简介
    JAVA学习笔记之变量
    JAVA学习笔记之类和对象
  • 原文地址:https://www.cnblogs.com/wangzhaobo/p/7419712.html
Copyright © 2011-2022 走看看