初级驱动第一天
Ubuntu12.04配置静态ip
- 使用ifconfig查看网卡名称
eth0 Link encap:Ethernet HWaddr 00:0c:29:28:be:0f
inet addr:192.168.30.54 Bcast:192.168.30.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe28:be0f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:12729336 errors:6827 dropped:7354 overruns:0 frame:0
TX packets:7217209 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1464520312 (1.4 GB) TX bytes:2296991300 (2.2 GB)
Interrupt:19 Base address:0x2000
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:4126 errors:0 dropped:0 overruns:0 frame:0
TX packets:4126 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:400935 (400.9 KB) TX bytes:400935 (400.9 KB)
eth0为网卡名;
- 第二步
sudo vim /etc/network/interfaces
修改为如下:
auto lo
iface lo inet loopback
auto eth0 //网卡
iface eth0 inet static //静态
address 192.168.30.54 //ip
netmask 255.255.255.0 //子网掩码
gateway 192.168.30.1 //网关
- 第三步
配置dns:
搜索当地dns然后写入配置文件
sudo vim /etc/resolvconf/resolv.conf.d/base
写入dns如下
nameserver 202.96.128.86
nameserver 8.8.8.8
- 第四步
初始化dns和网络:
sudo /etc/init.d/networking restart
* Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces
* Reconfiguring network interfaces... ssh stop/waiting
ssh start/running, process 13029
[ OK ]
zzw@ubuntu-stu:/mnt/hgfs/ubuntu&matebook$
sudo /etc/init.d/resolvconf restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service resolvconf restart
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop resolvconf ; start resolvconf. The restart(8) utility is also available.
resolvconf stop/waiting
resolvconf start/running
zzw@ubuntu-stu:/mnt/hgfs/ubuntu&matebook$
5.================================== 配置完成==========================================