如何解决由于没有此类设备,因此Mininet上的ISC DHCP失败
我正在尝试在mininet内的主机上安装dhcp服务器以进行SDN研究。但是,我遇到一个错误,找不到修复程序。您的建议将不胜感激!预先感谢!
当我运行$ service isc-dhcp-server restart时,这是/ var / log / syslog中的错误消息
Sep 24 22:55:46 sdn-VirtualBox sh[6580]: Wrote 0 leases to leases file.
Sep 24 22:55:46 sdn-VirtualBox dhcpd[6580]: h3-eth0 missing an interface address
Sep 24 22:55:46 sdn-VirtualBox sh[6580]: h3-eth0 missing an interface address
Sep 24 22:55:46 sdn-VirtualBox dhcpd[6580]: Error getting hardware address for "h3-eth0": No such device
Sep 24 22:55:46 sdn-VirtualBox sh[6580]: Error getting hardware address for "h3-eth0": No such device
但是,当我运行mininet> h3 ifconfig时,它确实显示了h3-eth0接口。
mininet> h3 ifconfig
h3-eth0: flags=4163<UP,broADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.16.1 netmask 255.255.255.0 broadcast 192.168.16.255
inet6 fe80::2c74:27ff:fead:e840 prefixlen 64 scopeid 0x20<link>
ether 2e:74:27:ad:e8:40 txqueuelen 1000 (Ethernet)
RX packets 220 bytes 22750 (22.7 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 95 bytes 6534 (6.5 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
我还如下配置/etc/dhcp/dhcpd.conf
subnet 192.168.16.0 netmask 255.255.255.0 {
range 192.168.16.20 192.168.16.254;
interface h3-eth0;
}
我的VM是带有VirtualBox的18.04.4 LTS。
这是我的Mininet设置:
import sys,time,logging
from mininet.topo import Topo
from mininet.cli import CLI
from mininet.log import setLogLevel
from mininet.net import Mininet
from mininet.node import DefaultController,RemoteController,OVSSwitch
class LinearTopo( Topo ):
"Simple topology example."
def __init__( self ):
"Create custom topo."
# Initialize topology
Topo.__init__( self )
def build(self):
# Add hosts and switches
h1 = self.addHost( 'h1') #,ip='192.168.16.11/24')
h2 = self.addHost( 'h2') #,ip='192.168.16.12/24')
h3 = self.addHost( 'h3') #,ip='192.168.16.13/24')
s1 = self.addSwitch( 's1' )
s2 = self.addSwitch( 's2' )
s3 = self.addSwitch( 's3' )
# Add links
self.addLink( h1,s1)
#self.addLink( h1,s2)
self.addLink( h2,s2)
self.addLink( h3,s3)
self.addLink( s1,s2)
def runLinearTopo(controller_ip):
"Bootstrap a Mininet network using the Minimal Topology"
# Create an instance of our topology
topo = LinearTopo()
# Create a network based on the topology using OVS and controlled by
# a remote controller.
net = Mininet(
topo=topo,controller=DefaultController,#lambda name: RemoteController( name,ip=controller_ip ),switch=OVSSwitch)
#autoSetMacs=True )
# Actually start the network
net.start()
time.sleep(1)
print("*** Configuring hosts interfaces ...")
h1,h2,h3 = net.get('h1','h2','h3')
h1.setIP("192.168.16.11/24")
h2.setIP("192.168.16.12/24")
h3.setIP("192.168.16.1/24")
h3.cmd('ip route add default via 192.168.16.1')
h3.cmd('echo "nameserver 8.8.8.8" >> /etc/resolv.conf')
print("*** Start DHCP server on h3 ...")
h3.cmd('sudo apt-get update')
h3.cmd('echo "interfaces=\\"h3-eth0\\"" >> /etc/default/isc-dhcp-server')
dhcp_config = """
subnet 192.168.16.0 netmask 255.255.255.0 {
range 192.168.16.20 192.168.16.254;
interface h3-eth0;
}
"""
h3.cmd('echo "%s" >> /etc/dhcp/dhcpd.conf' % dhcp_config)
h3.cmd("service isc-dhcp-server restart &")
h1.cmd("ip route add default via 192.168.16.1")
h2.cmd("ip route add default via 192.168.16.1")
#print("*** Obtain IP address for h1-eth1 from DHCP ...")
#h1.cmd("ifconfigh h1-eht1 0")
#h1.cmd("dhclient h1-eth1")
# Drop the user in to a CLI so user can run commands.
CLI( net )
# After the user exits the CLI,shutdown the network.
net.stop()
if __name__ == '__main__':
# This runs if this file is executed directly
setLogLevel( 'info' )
logging.info("Controller IP {}".format(sys.argv[1]))
runLinearTopo(sys.argv[1])
topos = { 'lineartopo': ( lambda: LinearTopo() ) }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。