linux开发板设置静态ip,ubuntu 设置静态网络ip和动态网络ip

一、设置静态网络ip

1.编辑/etc/network/interfaces文件:

vi /etc/network/interfaces

# The primary network interface

auto em1 //有的是eth0

#iface em1 inet dhcp //dhcp自动的,将这行注释掉

在 interfaces文件加入下面的内容

iface eth0 inet static //static为静态的

address 192.168.1.105 //ip地址

netmask 255.255.255.0 //子网掩码

gateway 192.168.1.2 //网关

broadcast 192.168.1.2 //广播

2.编辑/etc/resolv.conf,设置相应的DNS

nameserver 202.96.134.133

#nameserver 8.8.8.8 //谷歌dns解析,但是速度较慢

3.重启网卡

/etc/init.d/networking restart

二、设置动态网络ip

1.编辑/etc/network/interfaces文件:

# The primary network interface

auto em1 //有的是eth0

iface em1 inet dhcp //dhcp自动的,将这行打开,其他的都注释掉

2. 重启网卡

/etc/init.d/networking restart

如果出现

stop: Job failed while stopping

start: Job is already running: networking

那么重启方法

ifdown em1 && ifup em1


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部