Linux相关网络命令

手动临时设置IP
sudo ifconfig eth0 up 192.168.1.10
手动设置IP一般在系统重启后就失效

静态设置IP
Ubuntu网络配置信息保存在 /etc/network/interfaces 文件中,默认内容如下:
auto eth0
iface eth0 inet dhcp

auto lo
iface lo inet loopback

设置静态ip的方法如下:
使用root用户编辑 /etc/network/interfaces
i)注释掉第二行,设置静态ip有关参数
auto eth0
#iface eth0 inet dhcp

iface eth0 inet static
address *.*.*.*(合适的ip地址)
netmask 255.255.255.0
gateway *.*.*.*(合适的网关)

auto lo
iface lo inet loopback

ii)编辑 /etc/resolv.conf,设置dns
nameserver *.*.*.*(合适的dns)

iii)关闭后重启,使新设置生效
$sudo ifconfig eth0 down
$sudo ifconfig eth0 up
另外,重启网络的命令是 sudo /etc/init.d/networking restart  (对ubuntu而言)


以上方法都是属于命令行的方式,当然还有更简单的方法,就是直接在界面设置(和windows一样简单),前提能够找到设置的地方,具体方法找google或者baidu。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值