首页
社区
课程
招聘
[求助]配置MIPS的系统网络
2018-8-18 13:52 11128

[求助]配置MIPS的系统网络

2018-8-18 13:52
11128
搭建路由器实验环境终于 要成功了,这两天卡在了最后一步,网络配置这里,将问题说明一下:
```

sudo apt-get install bridge-utils uml-utilities

//查看Ubuntu系统的eth

root@richard-virtual-machine:~# ip a

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

       valid_lft forever preferred_lft forever

    inet6 ::1/128 scope host

       valid_lft forever preferred_lft forever

2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    link/ether 00:0c:29:5a:d8:65 brd ff:ff:ff:ff:ff:ff

    inet 192.168.2.184/24 brd 192.168.2.255 scope global dynamic eno16777736

       valid_lft 7043sec preferred_lft 7043sec

    inet6 fe80::20c:29ff:fe5a:d865/64 scope link

       valid_lft forever preferred_lft forever

root@richard-virtual-machine:~# dmesg | grep -i eth

[    1.976873] e1000 0000:02:01.0 eth0: (PCI:66MHz:32-bit) 00:0c:29:5a:d8:65

[    1.976879] e1000 0000:02:01.0 eth0: Intel(R) PRO/1000 Network Connection

[    1.986531] e1000 0000:02:01.0 eno16777736: renamed from eth0

# 修改ubuntu主机的网络配置文件 /etc/network/interfaces

root@richard-virtual-machine:~# sudo gedit /etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)

auto lo

iface lo inet loopback

auto eno16777736  

iface eno16777736 inet dhcp  

#auto br0  

iface br0 inet dhcp  

  bridge_ports eno16777736  

  bridge_maxwait 0

# 创建QEMU的网络接口启动脚本,重启网络使配置生效

root@richard-virtual-machine:~# sudo gedit /etc/network/interfaces

(gedit:92752): Gtk-WARNING **: Calling Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files

root@richard-virtual-machine:~# sudo gedit /etc/qemu-ifup

(gedit:92831): Gtk-WARNING **: Calling Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files

//在脚本文件/etc/qemu-ifup中写入如下的内容:

#!/bin/sh 

echo "Executing /etc/qemu-ifup" 

echo "Bringing $1 for bridged mode..." 

sudo /sbin/ifconfig $1 0.0.0.0 promisc up 

echo "Adding $1 to br0..." 

sudo /sbin/brctl addif br0 $1 

sleep 3

# 保存 文件/etc/qemu-ifup 以后,赋予文件/etc/qemu-ifup 可执行权限,然后重启网络使所有的配置生效。

root@ubuntu:~# sudo chmod a+x /etc/qemu-ifup

//重启网络使配置生效

root@richard-virtual-machine:~# sudo /etc/init.d/networking restart

[ ok ] Restarting networking (via systemctl): networking.service.

#启动桥连网络

root@richard-virtual-machine:~# sudo ifdown eno16777736

Killed old client process

Internet Systems Consortium DHCP Client 4.3.1

Copyright 2004-2014 Internet Systems Consortium.

All rights reserved.

For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eno16777736/00:0c:29:5a:d8:65

Sending on   LPF/eno16777736/00:0c:29:5a:d8:65

Sending on   Socket/fallback

DHCPRELEASE on eno16777736 to 192.168.2.1 port 67 (xid=0x1149c5ea)

root@richard-virtual-machine:~# sudo ifup br0

Internet Systems Consortium DHCP Client 4.3.1

Copyright 2004-2014 Internet Systems Consortium.

All rights reserved.

For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/br0/00:0c:29:5a:d8:65

Sending on   LPF/br0/00:0c:29:5a:d8:65

Sending on   Socket/fallback

DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 3 (xid=0xde368f31)

DHCPREQUEST of 192.168.2.183 on br0 to 255.255.255.255 port 67 (xid=0x318f36de)

DHCPOFFER of 192.168.2.183 from 192.168.2.1

DHCPACK of 192.168.2.183 from 192.168.2.1

bound to 192.168.2.183 -- renewal in 3486 seconds.

root@richard-virtual-machine:~# ifconfig  -a

br0       Link encap:以太网  硬件地址 00:00:00:00:00:00 

          UP BROADCAST MULTICAST  MTU:1500  跃点数:1

          接收数据包:7 错误:0 丢弃:0 过载:0 帧数:0

          发送数据包:8 错误:0 丢弃:0 过载:0 载波:0

          碰撞:0 发送队列长度:0

          接收字节:1157 (1.1 KB)  发送字节:1054 (1.0 KB)

eno16777736 Link encap:以太网  硬件地址 00:0c:29:5a:d8:65 

          inet 地址:192.168.2.183  广播:192.168.2.255  掩码:255.255.255.0

          inet6 地址: fe80::20c:29ff:fe5a:d865/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  跃点数:1

          接收数据包:876201 错误:0 丢弃:0 过载:0 帧数:0

          发送数据包:257164 错误:0 丢弃:0 过载:0 载波:0

          碰撞:0 发送队列长度:1000

          接收字节:1276194225 (1.2 GB)  发送字节:18046092 (18.0 MB)

lo        Link encap:本地环回 

          inet 地址:127.0.0.1  掩码:255.0.0.0

          inet6 地址: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:65536  跃点数:1

          接收数据包:2353 错误:0 丢弃:0 过载:0 帧数:0

          发送数据包:2353 错误:0 丢弃:0 过载:0 载波:0

          碰撞:0 发送队列长度:0

          接收字节:158317 (158.3 KB)  发送字节:158317 (158.3 KB)

(注意:这里的bro是没有inet 地址的,貌似有点问题,当然,这是我后来发现的)

#  运行 qemu-mips 32的虚拟机

// 虚拟机下载网址:https://people.debian.org/~aurel32/qemu/

root@richard-virtual-machine:~# sudo qemu-system-mips -M malta -kernel vmlinux-2.6.32-5-4kc-malta -hda debian_squeeze_mips_standard.qcow2 -append "root=/dev/sda1 console=tty0" -net nic,macaddr=00:16:3e:00:00:01 -net tap -nographic

Executing /etc/qemu-ifup

Bringing tap0 for bridged mode...

Adding tap0 to br0...

[    0.000000] Initializing cgroup subsys cpuset

[    0.000000] Initializing cgroup subsys cpu

[    0.000000] Linux version 2.6.32-5-4kc-malta (Debian 2.6.32-48squeeze4) (dannf@debian.org) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 Tue Sep 24 00:02:22 UTC 2013

[    0.000000]

[    0.000000] LINUX started...

[    0.000000] bootconsole [early0] enabled

[    0.000000] CPU revision is: 00019300 (MIPS 24Kc)

[    0.000000] FPU revision is: 00739300

[    0.000000] Determined physical RAM map:

[    0.000000]  memory: 00001000 @ 00000000 (reserved)

[    0.000000]  memory: 000ef000 @ 00001000 (ROM data)

[    0.000000]  memory: 005b7000 @ 000f0000 (reserved)

[    0.000000]  memory: 07958000 @ 006a7000 (usable)

[    0.000000] Wasting 54496 bytes for tracking 1703 unused pages

[    0.000000] Initrd not found or empty - disabling initrd

[    0.000000] Zone PFN ranges:

[    0.000000]   DMA      0x00000000 -> 0x00001000

[    0.000000]   Normal   0x00001000 -> 0x00007fff

[    0.000000] Movable zone start PFN for each node

[    0.000000] early_node_map[1] active PFN ranges

[    0.000000]     0: 0x00000000 -> 0x00007fff

[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 32511

[    0.000000] Kernel command line: root=/dev/sda1 console=tty0

[    0.000000] PID hash table entries: 512 (order: -1, 2048 bytes)

[    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)

[    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)

[    0.000000] Primary instruction cache 2kB, VIPT, 2-way, linesize 16 bytes.

[    0.000000] Primary data cache 2kB, 2-way, VIPT, no aliases, linesize 16 bytes

[    0.000000] Writing ErrCtl register=00000000

[    0.000000] Readback ErrCtl register=00000000

[    0.000000] Memory: 122952k/124256k available (3999k kernel code, 1128k reserved, 1084k data, 212k init, 0k highmem)

[    0.000000] SLUB: Genslabs=7, HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1

[    0.000000] Hierarchical RCU implementation.

[    0.000000] NR_IRQS:256

[    0.000000] CPU frequency 200.00 MHz

[    0.000000] Console: colour dummy device 80x25

[    0.000000] console [tty0] enabled, bootconsole disabled

Debian GNU/Linux 6.0 debian-mips ttyS0

而后登录debian-mips虚拟机:

root@debian-mips:~# ifconfig -a

eth1      Link encap:Ethernet  HWaddr 00:16:3e:00:00:01 

          BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

          Interrupt:10 Base address:0x1020

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:16436  Metric:1

          RX packets:8 errors:0 dropped:0 overruns:0 frame:0

          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:560 (560.0 B)  TX bytes:560 (560.0 B)

//通过 ifconfig 命令得到网络接口名称为 "eth1" 。因此需要 编辑 mips虚拟机 的 /etc/network/interfaces文件,修改网络接口的名称。

//修改之后为如下:

root@debian-mips:~# cat /etc/network/interfaces

# This file describes the network interfaces available on your system

# and how to activate them. For more information, see interfaces(5).

# The loopback network interface

auto lo

iface lo inet loopback

# The primary network interface

allow-hotplug eth1

iface eth1 inet dhcp

使用 ifup 命令启用 eth1 网络接口(这里终于出了问题,可能跟上面宿主机里面的br0有关系)

root@debian-mips:~# ifup eth1

Internet Systems Consortium DHCP Client 4.1.1-P1

Copyright 2004-2010 Internet Systems Consortium.

All rights reserved.

For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth1/00:16:3e:00:00:01

Sending on   LPF/eth1/00:16:3e:00:00:01

Sending on   Socket/fallback

DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 6

DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 9

DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 14

DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 8

DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 14

DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 10

No DHCPOFFERS received.

No working leases in persistent database - sleeping.

//再次查看ip,这里也出现了问题eth1的inet addr “消失”了

root@debian-mips:~# ifconfig -a

eth1      Link encap:Ethernet  HWaddr 00:16:3e:00:00:01 

          inet6 addr: fe80::216:3eff:fe00:1/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:0 (0.0 B)  TX bytes:2520 (2.4 KiB)

          Interrupt:10 Base address:0x1020

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:16436  Metric:1

          RX packets:8 errors:0 dropped:0 overruns:0 frame:0

          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:560 (560.0 B)  TX bytes:560 (560.0 B)

//显然这里虚拟机 网络是无法ping通的;但是宿主机却是可以与外界ping通的

root@debian-mips:~# ping www.baidu.com

ping: unknown host www.baidu.com

问题:我这里的mips的网络配置哪里出了问题,还请大佬指导一波





[培训]二进制漏洞攻防(第3期);满10人开班;模糊测试与工具使用二次开发;网络协议漏洞挖掘;Linux内核漏洞挖掘与利用;AOSP漏洞挖掘与利用;代码审计。

最后于 2018-8-19 15:27 被cdcdiot编辑 ,原因:
收藏
点赞0
打赏
分享
最新回复 (21)
雪    币: 11
活跃值: (12)
能力值: ( LV5,RANK:70 )
在线值:
发帖
回帖
粉丝
照片记录谁 2018-8-19 00:03
2
0
eth1是要桥接的网卡吗?根据ifup eth1的输出结果,发送DHCPDISCOVERY后没有收到DHCPOFFER的回复包,应该是对eth1的dhcp设置有问题。如果eth1是要桥接的网卡的话,好像要在/etc/network/interfaces里面将其设为dhcp。
雪    币: 223
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
cdcdiot 2018-8-19 10:28
3
0
root@debian-mips:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth1
iface eth1 inet dhcp
我是设置了的
雪    币: 223
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
cdcdiot 2018-8-19 10:29
4
0
照片记录谁 eth1是要桥接的网卡吗?根据ifup eth1的输出结果,发送DHCPDISCOVERY后没有收到DHCPOFFER的回复包,应该是对eth1的dhcp设置有问题。如果eth1是要桥接的网卡的话,好 ...
root@debian-mips:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth1
iface eth1 inet dhcp
我是设置了的
雪    币: 11
活跃值: (12)
能力值: ( LV5,RANK:70 )
在线值:
发帖
回帖
粉丝
照片记录谁 2018-8-19 21:48
5
0
cdcdiot root@debian-mips:~# cat /etc/network/interfaces # This file describes the network interfaces availa ...
外面的br0没有分配到地址,造成里面的eth1也没有地址,所以ping不通吧。另外,可以尝试ping IP地址试试(不过应该也不通),ping 域名可能由于DNS配置有问题造成无法进行域名解析。我昨天看了一下我之前搭建的环境,网络好像也有点问题了。。。等解决了可以相互交流下
雪    币: 223
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
cdcdiot 2018-8-19 22:00
6
0
照片记录谁 外面的br0没有分配到地址,造成里面的eth1也没有地址,所以ping不通吧。另外,可以尝试ping IP地址试试(不过应该也不通),ping 域名可能由于DNS配置有问题造成无法进行域名解析。我昨天 ...
可以
雪    币: 123
活跃值: (405)
能力值: ( LV2,RANK:15 )
在线值:
发帖
回帖
粉丝
伤字号 2018-8-20 10:03
7
0
你一开始的时候宿主机开启br0网卡之后 ifconfig的结果中应该是br0有inet ip,原来的网卡eno16777736不带ip的,在那里的时候配置就有问题了。检查一下配置文件写的是不是有问题。或者检查一下其他的配置文件。
雪    币: 223
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
cdcdiot 2018-8-20 10:16
8
0
伤字号 你一开始的时候宿主机开启br0网卡之后 ifconfig的结果中应该是br0有inet ip,原来的网卡eno16777736不带ip的,在那里的时候配置就有问题了。检查一下配置文件写的是不是有问题。 ...
那里配置文件确实有问题,关键 宿主机里面配置文件怎么改
雪    币: 123
活跃值: (405)
能力值: ( LV2,RANK:15 )
在线值:
发帖
回帖
粉丝
伤字号 2018-8-20 10:22
9
0
cdcdiot 那里配置文件确实有问题,关键 宿主机里面配置文件怎么改[em_15]
按道理来讲改了interfaces和qemu-ifup就可以了,所以我感觉多半是脚本中间哪里写错了。。
雪    币: 223
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
cdcdiot 2018-8-20 13:02
10
0
伤字号 按道理来讲改了interfaces和qemu-ifup就可以了,所以我感觉多半是脚本中间哪里写错了。。
我也是这么感觉的,脚本怎么改是关键。。。
雪    币: 123
活跃值: (405)
能力值: ( LV2,RANK:15 )
在线值:
发帖
回帖
粉丝
伤字号 2018-8-20 13:58
11
0
cdcdiot 我也是这么感觉的,脚本怎么改是关键。。。
把interfaces脚本改完之后,手动重启一下网卡,手动执行一下qemu-ifup里面的命令看看有没有报错
雪    币: 223
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
cdcdiot 2018-8-20 14:12
12
0
伤字号 把interfaces脚本改完之后,手动重启一下网卡,手动执行一下qemu-ifup里面的命令看看有没有报错
手动重启一下网卡不就是sudo /etc/init.d/networking restart这个命令么,上面是没有报错的,你说手动执行qemu-ifup里面的命令是不是.用这个命令:  ./qemu-ifup
雪    币: 123
活跃值: (405)
能力值: ( LV2,RANK:15 )
在线值:
发帖
回帖
粉丝
伤字号 2018-8-20 14:56
13
0
cdcdiot 手动重启一下网卡不就是sudo /etc/init.d/networking restart这个命令么,上面是没有报错的,你说手动执行qemu-ifup里面的命令是不是.用这个命令: ./qemu- ...
重启网卡:
ifdown eth0
ifup br0
手动执行有点麻烦,得去找qemu传了什么参数给qemu-ifup
雪    币: 223
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
cdcdiot 2018-8-20 16:15
14
0
伤字号 重启网卡: ifdown eth0 ifup br0 手动执行有点麻烦,得去找qemu传了什么参数给qemu-ifup
我是用 ifdown eno16777736和ifup br0重启 网卡的,当时是没有报错的,但是用 ifconfig命令,发现br0是没有inet addr的,启动debian-mips之后 ,会 发现Executing /etc/qemu-ifup

Bringing tap0 for bridged mode...

Adding tap0 to br0...
雪    币: 223
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
cdcdiot 2018-8-20 16:18
15
0
传递的参数就是tap0
雪    币: 223
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
cdcdiot 2018-8-24 15:17
16
0
照片记录谁 外面的br0没有分配到地址,造成里面的eth1也没有地址,所以ping不通吧。另外,可以尝试ping IP地址试试(不过应该也不通),ping 域名可能由于DNS配置有问题造成无法进行域名解析。我昨天 ...
你网络环境搭建好没
雪    币: 223
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
cdcdiot 2018-8-24 17:33
17
0
照片记录谁 外面的br0没有分配到地址,造成里面的eth1也没有地址,所以ping不通吧。另外,可以尝试ping IP地址试试(不过应该也不通),ping 域名可能由于DNS配置有问题造成无法进行域名解析。我昨天 ...
这个问题我已经解决了,谢谢各位大佬
雪    币: 11
活跃值: (12)
能力值: ( LV5,RANK:70 )
在线值:
发帖
回帖
粉丝
照片记录谁 2018-8-26 17:36
18
0
cdcdiot 你网络环境搭建好没
没有,我后来看了qemu wiki上的网络接口配置,试了好几种qemu-ifup脚本,还是有点问题,仿真环境起来之后,里面的网卡还是没有分配到地址。外面的br0有地址,但tap0没有地址。
雪    币: 223
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
cdcdiot 2018-8-26 18:06
19
0
照片记录谁 没有,我后来看了qemu wiki上的网络接口配置,试了好几种qemu-ifup脚本,还是有点问题,仿真环境起来之后,里面的网卡还是没有分配到地址。外面的br0有地址,但tap0没有地址。
你还是按原来那种配置试试看,不行就重启一下试一试
雪    币: 41
活跃值: (283)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
溟秋 2020-3-6 15:57
20
0
一样的问题 请问楼主最后是怎么解决的
雪    币: 41
活跃值: (283)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
溟秋 2020-3-6 17:18
21
0
问题已经解决... 一样是br0处没地址
雪    币: 2250
活跃值: (180)
能力值: ( LV3,RANK:30 )
在线值:
发帖
回帖
粉丝
岁月别催 2020-5-26 18:58
22
0
请教下怎么解决的?
游客
登录 | 注册 方可回帖
返回