ubuntu14.04配置静态ip

2017-04-27 10:42

    由于用Linux虚拟机做嵌入式开发,公司原有的DHCP网络导致在Win10下访问虚拟机时IP地址常变,给开发带来不便,故将DHCP改为STATIC,步骤:

        1.sudo vim /etc/network/interfaces

            添加如下内容:

                auto eth0

                iface eth0 inet static

                address 192.168.1.119 

                netmask 255.255.255.0

                gateway 192.168.1.1

            保存退出。

        2.sudo vim /etc/NetworkManager/NetworkManager.conf

            将managed=false改为true

            保存退出。

        3.sudo vim /etc/resolv.conf

            添加如下内容:

                nameserver 192.168.1.1

                nameserver 220.170.64.68

            说明:本步骤改完后重启,会恢复为原有样子。故需要执行:

                sudo vim /etc/resolvconf/resolv.conf.d/base

                    同样添加:

                        nameserver 192.168.1.1

                        nameserver 220.170.64.68

                    保存退出。

        4.sudo /etc/init.d/networking restart提示如下错误:

            stop:Job failed while stopping

            start:Job is already running:networking

            是因为新版本ubuntu不再支持老命令,使用:

                service network-manager restart即可。

            或reboot下机器即可。若重启后设置无效,则需仔细检查上述步骤。