Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When i run the program. Error: network is unreachable #1223

Open
KMS07 opened this issue Apr 11, 2024 · 1 comment
Open

When i run the program. Error: network is unreachable #1223

KMS07 opened this issue Apr 11, 2024 · 1 comment

Comments

@KMS07
Copy link

KMS07 commented Apr 11, 2024

from mininet.net import Mininet
from mininet.node import Host, Node
from mininet.cli import CLI
from mininet.link import TCLink

def ipv6_to_ipv4_tunnel():
    net = Mininet()

    # IPv6 hosts
    h1 = net.addHost('h1', ip6='2001:db8:1::1/64', ipv6_default=True)
    h2 = net.addHost('h2', ip6='2001:db8:1::2/64', ipv6_default=True)

    # IPv4 host
    h3 = net.addHost('h3', ip='192.168.1.10/24', defaultRoute='via 10.0.0.1')

    # Router for 6to4 tunnel
    r0 = net.addHost('r0', cls=Node, ip='172.16.0.1/30')

    # Links (h1, h2 connect to router with IPv6)
    net.addLink(h1, r0, intfName1='h1-eth0', intfName2='r0-eth0', params1={'ip': '2001:db8:1::1/64'}, params2={'ip': '2001:db8:1::2/64'}, ipv6=True)
    net.addLink(h2, r0, intfName1='h2-eth0', intfName2='r0-eth1', params1={'ip': '2001:db8:1::2/64'}, params2={'ip': '2001:db8:1::1/64'}, ipv6=True)

    # Link between router and h3 (uses IPv4)
    net.addLink(r0, h3, intfName1='r0-eth2', params1={'ip': '172.16.0.1/30'}, params2={'ip': '192.168.1.1/24'}, ipv4=True, cls=TCLink, bw=10)

    # Configure 6to4 tunnel on router
    r0.cmd('ip tunnel add tun0 mode sit remote 192.0.2.1 local 192.0.2.2')
    r0.cmd('ip link set dev tun0 up')
    r0.cmd('ip addr add 2002:beef::1/64 dev tun0')
    r0.cmd('ip -6 route add ::/0 via 2002:c000:201::1 dev tun0')

    net.start()

    # Add default routes for h1 and h2
    h1.cmd('route add default gw 172.16.0.1')
    h2.cmd('route add default gw 172.16.0.1')

    # Test ping between IPv6 and IPv4 hosts
    print(h1.cmd('ping 192.168.1.10 -c 4'))
    print(h3.cmd('ping6 2001:db8:1::1 -c 4'))

    CLI(net)

    net.stop()

if __name__ == '__main__':
    ipv6_to_ipv4_tunnel()
@root-hbx
Copy link

If you have ruled out other potential errors such as

  • routing configuration
  • IPv6 configuration
  • subnet masks
  • IP Addr conflicts

There is a subtle error to consider:
In Mininet, by default, there may be firewall rules restricting network communication.

You can try disabling the firewall in the script or manually configuring the relevant rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants