- Press the Windows key.
- Type Notepad in the search field.
- In the search results, right-click Notepad and select Run as administrator.
- From Notepad, open the following file: c:\Windows\System32\Drivers\etc\hosts
- Make the necessary changes to the file.
- Click File > Save to save your changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Usage:: | |
cat momentary.txt | python translate.py >output.txt | |
''' | |
import sys | |
import csv | |
# create a CSV reader | |
reader = csv.reader(sys.stdin, dialect='excel-tab') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fjorton import fjorton | |
from fjorton import apply | |
from pyroute2 import IPRoute | |
from functools import partial | |
@fjorton | |
def f(): | |
with IPRoute() as ip: | |
ip.get_links() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: from pyroute2 import IPDB | |
In [2]: ip = IPDB() | |
# create future VRF port | |
In [3]: ip.create(ifname='v0p0', kind='dummy').commit() | |
Out[3]: {'family': 0, 'txqlen': 1000, 'ipdb_scope': 'system', 'index': 1118, 'operstate': 'DOWN', 'num_tx_queues': 1, 'group': 0, 'carrier_changes': 0, 'unknown': '08:00:29:00:00:00:01:00', 'ipaddr': [], 'neighbours': [], 'ifname': 'v0p0', 'promiscuity': 0, 'linkmode': 0, 'broadcast': 'ff:ff:ff:ff:ff:ff', 'address': 'f6:22:cf:07:8a:bc', 'vlans': [], 'ipdb_priority': 0, 'change': 4294967295, 'kind': 'dummy', 'qdisc': 'noop', 'mtu': 1500, 'num_rx_queues': 1, 'carrier': 1, 'flags': 130, 'ifi_type': 1, 'proto_down': 0, 'ports': []} | |
# create VRF interface | |
In [4]: ip.create(ifname='v0', kind='vrf', vrf_table=20).commit() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"os" | |
"time" | |
"github.com/vishvananda/netlink" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyroute2 import IPDB | |
from pyroute2 import netns | |
with IPDB() as ip: | |
ip.create(ifname='v0', kind='bridge').commit() | |
map(lambda x: ip.create(ifname='v0p%02i' % x, | |
peer='p0p%02i' % x, | |
kind='veth').commit(), range(20)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_iface_to_netns(if_name, ns_name): | |
# | |
# init IPDB and netns | |
ipdb = IPDB() | |
netns = None | |
# | |
# try to perform the operation | |
try: | |
# NetNS() constructor also can raise exceptions, | |
# so put it under try/catch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_iface_to_netns(if_name, ns_name): | |
# | |
# IPDB instantiation, as well as NetNS instantiation, | |
# are expensive operations. NetNS spawns an additional | |
# process, and IPDB populates itself with all the data | |
# from the operating system networking. | |
# | |
# Maybe, it would be not a bad idea to keep IPDB as a | |
# long-running global object, or like that. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo python | |
Python 2.7.5 (default, Nov 3 2014, 14:26:24) | |
[GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> from pyroute2 import IPDB | |
>>> from pyroute2 import NetNS | |
>>> ip1 = IPDB() | |
>>> ip2 = IPDB(nl=NetNS('test')) | |
>>> ip1.by_name.keys() | |
['bond0', 'lo', 'vnet0', 'em1', 'wlo1', 'dummy0', 'v13p0', 'virbr0-nic', 'virbr0'] |