码迷,mamicode.com
首页 > 系统相关 > 详细

ubuntu设置IP地址、网关的方法

时间:2017-11-03 14:15:50      阅读:308      评论:0      收藏:0      [点我收藏+]

标签:ons   add   over   ror   term   start   rmi   net   space   

打开terminal(用Ctrl+Alt+T打开)
1. 输入ifconfig 
打印如下:
enp1s0    Link encap:Ethernet  HWaddr 6c:4b:90:0b:53:be  
          inet addr:192.168.1.101  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::1fbf:55e3:1c4c:c79d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:144897 errors:0 dropped:630 overruns:0 frame:0
          TX packets:13548 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:13441598 (13.4 MB)  TX bytes:1943215 (1.9 MB)
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:7441 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7441 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:727906 (727.9 KB)  TX bytes:727906 (727.9 KB)

wlp2s0    Link encap:Ethernet  HWaddr 34:f6:4b:8e:8e:83  
          inet addr:192.168.17.208  Bcast:192.168.17.255  Mask:255.255.255.0
          inet6 addr: fe80::7b1:7fd6:cdbc:29a0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:39311 errors:0 dropped:0 overruns:0 frame:0
          TX packets:34360 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:19874047 (19.8 MB)  TX bytes:6833538 (6.8 MB)

2.开始设置IP,网关等
sudo vi /etc/network/interfaces
#静态设置IP地址
auto lo 
iface lo inet loopback 
 
auto enp1s0
iface enp1s0 inet static
        address 192.168.12.89(换成你的IP地址)
        netmask 255.255.255.0
        gateway 192.168.12.1(换成你的网关)
#自动获得IP地址
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
 
3.重新启动网卡
sudo /etc/init.d/networking restart
 
完成
 

ubuntu设置IP地址、网关的方法

标签:ons   add   over   ror   term   start   rmi   net   space   

原文地址:http://www.cnblogs.com/ancongliang/p/7777739.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!