本文整理汇总了Python中mininet.node.Host.config方法的典型用法代码示例。如果您正苦于以下问题:Python Host.config方法的具体用法?Python Host.config怎么用?Python Host.config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.node.Host
的用法示例。
在下文中一共展示了Host.config方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: config
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
def config(self, **kwargs):
Host.config(self, **kwargs)
debug("configuring route %s" % self.route)
self.cmd('ip addr add %s dev %s-eth0' % (self.ip, self.name))
self.cmd('ip route add default via %s' % self.route)
示例2: config
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
def config(self, **kwargs):
Host.config(self, **kwargs)
self.cmd('sysctl net.ipv4.ip_forward=1')
for intf, attrs in self.intfDict.items():
self.cmd('ip addr flush dev %s' % intf)
if 'mac' in attrs:
self.cmd('ip link set %s down' % intf)
self.cmd('ip link set %s address %s' % (intf, attrs['mac']))
self.cmd('ip link set %s up ' % intf)
self.nameToIntf[intf].mac=attrs['mac']
# for addr in attrs['ipAddrs']:
if 'vlan' in attrs:
# self.cmd('ip addr flush dev %s')
self.cmd('ip link add link %s name %s.%s type vlan id %s' % (intf, intf, attrs['vlan'], attrs['vlan']))
self.cmd('ip addr add %s dev %s.%s' % (attrs['ipAddrs'], intf, attrs['vlan']))
self.cmd('ip link set dev %s.%s up' % (intf, attrs['vlan']))
if ('ipAddrs' in attrs) & ('vlan' not in attrs):
self.cmd('ip addr add %s dev %s' % (attrs['ipAddrs'], intf))
self.nameToIntf[intf].ip=attrs['ipAddrs'].split('/')[0]
self.nameToIntf[intf].prefixLen=attrs['ipAddrs'].split('/')[1]
self.cmd('%s/zebra -d -f %s -z %s/zebra%s.api -i %s/zebra%s.pid' % (
QUAGGA_DIR, self.zebraConfFile, QUAGGA_RUN_DIR, self.name, QUAGGA_RUN_DIR, self.name))
self.cmd('%s/bgpd -d -f %s -z %s/zebra%s.api -i %s/bgpd%s.pid' % (
QUAGGA_DIR, self.quaggaConfFile, QUAGGA_RUN_DIR, self.name, QUAGGA_RUN_DIR, self.name))
for attrs in self.ARPDict.itervalues():
if 'localdev' in attrs:
self.cmd('ip route add %s%s dev %s' % (attrs['remoteIP'], attrs['remoteMask'], attrs['localdev']))
self.setARP(attrs['remoteIP'], attrs['remoteMAC'])
elif 'nexthop' in attrs:
self.cmd('ip route add %s%s via %s' % (attrs['remoteIP'], attrs['remoteMask'], attrs['nexthop']))
self.setARP(attrs['nexthop'], attrs['remoteMAC'])
示例3: config
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
def config(self, **kwargs):
Host.config(self, **kwargs)
debug("configuring route %s" % self.gateway)
self.cmd('ip addr flush dev %s' % self.defaultIntf())
for ip in self.ips:
self.cmd('ip addr add %s dev %s' % (ip, self.defaultIntf()))
self.cmd('ip route add default via %s' % self.gateway)
示例4: config
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
def config(self, **kwargs):
Host.config(self, **kwargs)
self.cmd('sysctl net.ipv4.ip_forward=1')
for intf, attrs in self.intfDict.items():
self.cmd('ip addr flush dev %s' % intf)
if 'mac' in attrs:
self.cmd('ip link set %s down' % intf)
self.cmd('ip link set %s address %s' % (intf, attrs['mac']))
self.cmd('ip link set %s up ' % intf)
for addr in attrs['ipAddrs']:
self.cmd('ip addr add %s dev %s' % (addr, intf))
self.cmd('/usr/lib/quagga/zebra -d -f %s -z %s/zebra%s.api -i %s/zebra%s.pid' % (self.zebraConfFile, QUAGGA_RUN_DIR, self.name, QUAGGA_RUN_DIR, self.name))
self.cmd('/usr/lib/quagga/bgpd -d -f %s -z %s/zebra%s.api -i %s/bgpd%s.pid' % (self.quaggaConfFile, QUAGGA_RUN_DIR, self.name, QUAGGA_RUN_DIR, self.name))
示例5: config
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
def config(self, **kwargs):
Host.config(self, **kwargs)
intf = self.defaultIntf()
self.vlanIntf = "%s.%s" % (intf, self.vlan)
self.cmd('ip -4 addr flush dev %s' % intf)
self.cmd('ip link add link %s name %s type vlan id %s' % (intf, self.vlanIntf, self.vlan))
self.cmd('ip link set up %s' % self.vlanIntf)
for ip in self.ips:
self.cmd('ip addr add %s dev %s' % (ip, self.vlanIntf))
self.cmd('ip route add default via %s' % self.gateway)
intf.name = self.vlanIntf
self.nameToIntf[self.vlanIntf] = intf
示例6: config
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
def config(self, **kwargs):
Host.config(self, **kwargs)
self.cmd('sysctl net.ipv4.ip_forward=1')
for intf, attrs in self.intfDict.items():
self.cmd('ip addr flush dev %s' % intf)
if 'mac' in attrs:
self.cmd('ip link set %s down' % intf)
self.cmd('ip link set %s address %s' % (intf, attrs['mac']))
self.cmd('ip link set %s up ' % intf)
for addr in attrs['ipAddrs']:
print str(attrs)
mask = attrs['mask']
gateway = attrs['gateway']
# print str('ifconfig %s %s netmask %s' % (intf, addr, mask))
self.cmd('ifconfig %s %s netmask %s' % (intf, addr, mask))
self.cmd('route add default gw %s' % (gateway))
示例7: config
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
def config(self, *_parm, **_params):
rv = Host.config(self, *_parm, **_params)
qcall(self,self.cmd,'iptables -P INPUT ACCEPT')
qcall(self,self.cmd,'iptables -P OUTPUT ACCEPT')
qcall(self,self.cmd,'iptables -P FORWARD DROP')
qcall(self,self.cmd,'iptables -A FORWARD -p icmp -j ACCEPT')
qcall(self,self.cmd,'iptables -A FORWARD -i s1-lan -o s1-wan -p tcp --sport 1024:65535 --dport 80 -j ACCEPT')
qcall(self,self.cmd,'iptables -A FORWARD -i s1-wan -o s1-lan -p tcp --sport 80 --dport 1024:65535 -j ACCEPT')
#qcall(self,self.cmd,'iptables -A FORWARD -i s1-lan -o s1-wan -p tcp --sport 49152:65535 --dport 80 -j ACCEPT')
#qcall(self,self.cmd,'iptables -A FORWARD -i s1-wan -o s1-lan -p tcp --sport 80 --dport 49152:65535 -j ACCEPT')
self.ifc()
qcall(self,self.cmd,'ip route add default via 10.0.2.1 dev s1-wan')
self.cmd('sysctl -w net.ipv4.ip_forward=1')
return rv
示例8: config
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
def config(self, **kwargs):
Host.config(self, **kwargs)
mtu = "ifconfig "+self.name+"-eth0 mtu 1490"
self.cmd(mtu)
self.cmd('ip route add default via %s' % self.gateway)
示例9: config
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
def config(self, **kwargs):
Host.config(self, **kwargs)
debug("configuring route %s" % self.route)
self.cmd('ip route add default via %s' % self.route)
示例10: config
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
def config(self, **kwargs):
Host.config(self, **kwargs)
debug("configuring gateway %s" % (self.gw, ))
self.cmd('ip route add default via %s' % (self.gw, ))