Giter VIP home page Giter VIP logo

veth-example's Introduction

veth-example

Environment

  • lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.5 LTS
Release:    18.04
Codename:   bionic

Example

  • ip netns add test
  • ip netns
test
  • ip link add veth0 type veth peer name veth1 netns test: create a pair and then assign veth1 into namespace test
  • ip addr show veth0: show it in the global namespace
130: veth0@if2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 8e:4c:e4:f8:df:aa brd ff:ff:ff:ff:ff:ff link-netnsid 15
  • ip netns exec test ip addr: run ip addr under the test network namespace.
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: veth1@if130: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether ca:83:85:f5:36:fe brd ff:ff:ff:ff:ff:ff link-netnsid 0
  • ip addr add 10.1.1.1/24 dev veth0 && ip addr show veth0
130: veth0@if2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 8e:4c:e4:f8:df:aa brd ff:ff:ff:ff:ff:ff link-netnsid 15
    inet 10.1.1.1/24 scope global veth0
       valid_lft forever preferred_lft forever
  • ip netns exec test ip addr add 10.1.1.2/24 dev veth1 && ip netns exec test ip addr show veth1
2: veth1@if130: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether ca:83:85:f5:36:fe brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.1.1.2/24 scope global veth1
       valid_lft forever preferred_lft forever
  • ip link set veth0 up
  • ip netns exec test ip link set veth1 up
  • ping -I 10.1.1.1 10.1.1.2
PING 10.1.1.2 (10.1.1.2) from 10.1.1.1 : 56(84) bytes of data.
64 bytes from 10.1.1.2: icmp_seq=1 ttl=64 time=0.060 ms
64 bytes from 10.1.1.2: icmp_seq=2 ttl=64 time=0.033 ms
64 bytes from 10.1.1.2: icmp_seq=3 ttl=64 time=0.033 ms

Troubleshooting

  • ip netns del test: delete the namespace test
  • ip link delete veth0: delete the interface veth0

References

veth-example's People

Contributors

jimlinntu avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.