mininet + mnec +bgpd

root@ubuntu:/home/ubuntu# ps -elf | grep r3
0 S root     22962 22933  0  80   0 -  1367 select 19:41 pts/10   00:00:00 bash --norc -mis mininet:mgntr3
4 S root     22970 22933  0  80   0 -  1367 select 19:41 pts/14   00:00:00 bash --norc -mis mininet:r3
1 S quagga   23897     1  0  80   0 -  1251 select 19:41 ?        00:00:00 zebra -d -f /etc/quagga/sdn-ip-topology/configs/zebra.conf -z /var/run/quagga/zebrar3.api -i /var/run/quagga/zebrar3.pid
1 S quagga   23899     1  0  80   0 -  1962 select 19:41 ?        00:00:00 bgpd -d -f /etc/quagga/sdn-ip-topology/configs/quagga3.conf -z /var/run/quagga/zebrar3.api -i /var/run/quagga/bgpdr3.pid

def main():
    os.system("mnexec -a %s %s" % (22970, 'telnet localhost bgpd'))


if __name__ == '__main__':
    main()
"run.py" 63L, 1630C written     
root@ubuntu:/home/ubuntu/# python run.py 
/proc/22970/ns/net: No such file or directory
root@ubuntu:/home/ubuntu/# ps -elf | grep r3
0 S root     25935 25906  0  80   0 -  1367 select 19:48 pts/10   00:00:00 bash --norc -mis mininet:mgntr3
4 S root     25943 25906  0  80   0 -  1367 select 19:48 pts/14   00:00:00 bash --norc -mis mininet:r3
1 S quagga   26860     1  0  80   0 -  1251 select 19:48 ?        00:00:00 zebra -d -f /etc/quagga/sdn-ip-topology/configs/zebra.conf -z /var/run/quagga/zebrar3.api -i /var/run/quagga/zebrar3.pid
1 S quagga   26862     1  0  80   0 -  1962 select 19:48 ?        00:00:00 bgpd -d -f /etc/quagga/sdn-ip-topology/configs/quagga3.conf -z /var/run/quagga/zebrar3.api -i /var/run/quagga/bgpdr3.pid
0 S root     27442 24481  0  80   0 -  1097 pipe_w 19:48 pts/25   00:00:00 grep --color=auto r3
root@ubuntu:/home/ubuntu/# 
python run.py 
Trying ::1...
Connected to localhost.
Escape character is '^]'.

Hello, this is Quagga (version 1.2.4).
Copyright 1996-2005 Kunihiro Ishiguro, et al.


User Access Verification

Password: 
r3> en
r3# show run

Current configuration:
!
hostname r3
password sdnip
log stdout
!
router bgp 65003
 bgp router-id 10.0.3.1
 network 192.168.3.0/24
 timers bgp 3 9
 neighbor 10.0.3.101 remote-as 65000
 neighbor 10.0.3.101 ebgp-multihop 255
 neighbor 10.0.3.101 advertisement-interval 5
 neighbor 10.0.3.101 timers connect 5
!
 address-family ipv6
 exit-address-family
 exit
!
line vty
!
end
r3# 
r3# 
def main():
    os.system("mnexec -a %s %s" % (25943, 'telnet localhost 2605'))


if __name__ == '__main__':
    main()
"run.py" 63L, 1630C written     
root@ubuntu:/home/ubuntu/jvimal-bgp-789055b95a66# python run.py 
Trying ::1...
Connected to localhost.
Escape character is '^]'.

Hello, this is Quagga (version 1.2.4).
Copyright 1996-2005 Kunihiro Ishiguro, et al.


User Access Verification

Password: 
r3> en
r3# show run

Current configuration:
!
hostname r3
password sdnip
log stdout
!
router bgp 65003
 bgp router-id 10.0.3.1
 network 192.168.3.0/24
 timers bgp 3 9
 neighbor 10.0.3.101 remote-as 65000
 neighbor 10.0.3.101 ebgp-multihop 255
 neighbor 10.0.3.101 advertisement-interval 5
 neighbor 10.0.3.101 timers connect 5
!
 address-family ipv6
 exit-address-family
 exit
!
line vty
!
end
r3# 
r3# 
def main():
    os.system("mnexec -a %s %s" % (25943, 'telnet localhost 2604'))


if __name__ == '__main__':
    main()
"run.py" 63L, 1630C written
root@ubuntu:/home/ubuntu/jvimal-bgp-789055b95a66# python run.py 
Trying ::1...
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
root@ubuntu:/home/ubuntu/jvimal-bgp-789055b95a66# vi run.py 
    if pid is None:
        print "node `%s' not found" % (FLAGS.node)
        sys.exit(1)

    cmd = ' '.join(FLAGS.cmd)
    os.system("mnexec -a %s %s" % (pid, cmd))
'''
def main():
    os.system("mnexec -a %s %s" % (25943, 'telnet localhost 2601'))


if __name__ == '__main__':
    main()
"run.py" 63L, 1630C written
root@ubuntu:/home/ubuntu/jvimal-bgp-789055b95a66# python run.py 
Trying ::1...
Connected to localhost.
Escape character is '^]'.

Hello, this is Quagga (version 1.2.4).
Copyright 1996-2005 Kunihiro Ishiguro, et al.


User Access Verification

Password: 
zebra> en
zebra# show run

Current configuration:
!
hostname zebra
password sdnip
log stdout
!
interface lo
!
interface r3-eth0
!
interface r3-eth1
!
 --More-- 
root@mininet-vm:~/srv6_Sandbox# ps -elf | grep r1
4 S root     15166     1  0  80   0 -  6951 poll_s Aug11 ?        00:00:00 zebra -f /tmp/zebra_r1.cfg -i /tmp/zebra_r1.pid -z /tmp/quagga_r1.api -u root -k
4 S root     26941 26883  0  80   0 -  5475 wait_w 01:32 pts/16   00:00:00 bash --norc --noediting -is mininet:r1
0 S root     29598 17896  0  80   0 -  3714 pipe_w 02:11 pts/10   00:00:00 grep --color=auto r1
root@mininet-vm:~/srv6_Sandbox# mnexec -a 26941 telnet localhost bgpd
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
root@mininet-vm:~/srv6_Sandbox# mnexec -a 26941 telnet localhost zebra
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
root@mininet-vm:~/srv6_Sandbox# mnexec -a 26941 ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    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 fc00:1::1/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: r1-eth2@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 0e:30:22:49:41:0f brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.0.0.2/24 scope global r1-eth2
       valid_lft forever preferred_lft forever
    inet6 fe80::c30:22ff:fe49:410f/64 scope link 
       valid_lft forever preferred_lft forever
3: r1-eth3@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 76:3f:05:aa:15:6b brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 2001:1a::1/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::743f:5ff:feaa:156b/64 scope link 
       valid_lft forever preferred_lft forever
4: r1-eth0@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether b6:58:af:69:b0:d4 brd ff:ff:ff:ff:ff:ff link-netnsid 1
    inet6 2001:12::1/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::b458:afff:fe69:b0d4/64 scope link 
       valid_lft forever preferred_lft forever
5: r1-eth1@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 1a:e0:d2:f8:57:0f brd ff:ff:ff:ff:ff:ff link-netnsid 2
    inet6 2001:14::1/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::18e0:d2ff:fef8:570f/64 scope link 
       valid_lft forever preferred_lft forever
root@mininet-vm:~/srv6_Sandbox# 
root@mininet-vm:~/srv6_Sandbox# mnexec -a 26941 netstat -lpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node   PID/Program name     Path
root@mininet-vm:~/srv6_Sandbox# 
root@mininet-vm:~# ps -elf | grep r1
4 S root      2318  2274  0  80   0 -  5475 wait_w 06:47 pts/4    00:00:00 bash --norc --noediting -is mininet:r1
4 S root      2592  2274  0  80   0 -  6952 poll_s 06:47 ?        00:00:00 zebra -f /tmp/zebra_r1.cfg -i /tmp/zebra_r1.pid -z /tmp/quagga_r1.api -u root -k
0 S root      2682  2664  0  80   0 -  3714 pipe_w 06:48 pts/8    00:00:00 grep --color=auto r1
root@mininet-vm:~# mnexec -a 2318  telnet localhost zebra
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
root@srv6:~/srv6_Sandbox# mnexec -a 2079  bash
root@srv6:~/srv6_Sandbox# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    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: a-eth0@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether ca:bc:8e:af:35:12 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.0.0.1/24 scope global a-eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::c8bc:8eff:feaf:3512/64 scope link 
       valid_lft forever preferred_lft forever
3: a-eth1@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether d6:e0:5d:40:58:12 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 2001:1a::2/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::d4e0:5dff:fe40:5812/64 scope link 
       valid_lft forever preferred_lft forever
root@srv6:~/srv6_Sandbox# 
原文地址:https://www.cnblogs.com/dream397/p/13337127.html