ubuntu ip设置

来源:互联网 发布:ubuntu桌面版什么意思 编辑:程序博客网 时间:2024/06/06 10:56

一.测试网卡是否正常工作

    1.ping 127.0.0.1

    2.ping gateway

    3.ping hostname 可以用hostname命令查看)


二.查看网卡配置(ifconfig)

    1.查看DNS,Default getway Sever地址是否正确


三.修改网络配置

     1.禁用IPV6

        sudo vim /etc/modprobe.d/blacklist.conf

        在文档最后添加

        blacklist ipv6

     2.设置IP

        sudo ifconfig eth0 192.168.1.3 netmask 255.255.255.0

     3.设置网关

        sudo route add default gw 192.168.1.1

     4.设置DNS

        sudo vim /etc/resolv.conf

        在文档中加入

        nameserver DNS1

        nameserver DNS2

     5.重启网络服务

        sudo /etc/init.d/networking restart


四.通过修改文件设置网络

     1.DHCP

        sudo vim /etc/network/interfaces

替换eth0 行

        #The primary network interface - use DHCP to find our address

        auto eth0

        iface eth0 inet dhcp

        也可以使用以下命令来获取地址

        sudo dhclient eth0

     2.静态IP

        sudo vim /etc/network/interfaces

替换eth0 行

#The primary network interface

auto eth0

iface eth0 inet static

address 192.168.1.3

gateway 192.168.1.1

netmask 255.255.255.0

#network 192.168.1.0

#broadcast 192.168.1.255

     3.重启网络


五.设置主机名

     sudo /bin/hostname newname

原创粉丝点击