iproute for Mac
Project description
This is a macOS network wrapper to imitate GNU/Linux iproute2 suite, inspired by the iproute2mac project.
Working staff
Command ip:
objects |
implemented |
supported |
note |
---|---|---|---|
address |
yes |
yes |
|
address |
yes |
yes |
|
addrlabel |
no |
? |
IPv6 protocol address label |
maddress |
no |
? |
|
route |
yes |
yes |
|
rule |
no |
? |
|
neighbor |
yes |
yes |
|
ntable |
no |
? |
|
ntbl |
no |
? |
|
link |
yes |
yes |
|
l2tp |
no |
? |
|
fou |
no |
? |
IP-IP tunnel over UDP? |
ila |
no |
? |
IPv6 Identifier Locator Addressing |
macsec |
no |
no |
|
tunnel |
no |
yes |
IP-IP only |
tuntap |
no |
? |
Tunnelblick third party tuntaposx? |
token |
no |
? |
May be related to non-numeric IPv6 mask? |
tcpmetrics |
no |
? |
|
monitor |
no |
no |
|
xfrm |
no |
no |
|
mroute |
no |
? |
|
mrule |
no |
? |
|
netns |
no |
no |
|
netconf |
no |
yes |
|
vrf |
no |
? |
|
sr |
no |
? |
IPv6 Segment Routing management |
nexthop |
no |
? |
|
mptcp |
no |
no |
Multipath TCP |
ioam |
no |
? |
IPv6 In-situ OAM (IOAM) |
help |
yes |
yes |
|
stats |
no |
? |
Command bridge:
objects |
implemented |
supported |
note |
---|---|---|---|
link |
yes |
yes |
show only |
fdb |
yes |
yes |
show only |
Examples:
ip address [ list | show ]
ip address { add | change | replace | delete }
ip link [ list | show ]
ip link { add | set | change | delete }
ip route [ list | show ]
ip route { add | change | replace | delete }
ip route get
ip neigh [ list | show ]
ip neigh flush
bridge link [ list | show ]
bridge fdb [ list | show ]
Installation
Homebrew
The preferred method of installation is Homebrew.
In order to use this tap, you can install directly the package:
brew install signal-09/tap/iproute4mac
Or subscribe the tap repository and then install the package:
brew tap signal-09/tap
brew install iproute4mac
PyPI
Create a Virtual Environment and upgrade pip module:
python3 -m venv venv
source venv/bin/activate
python3 -m pip install -U pip
Then install iproute4mac:
python3 -m pip install iproute4mac
Usage
iproute4mac try to imitate as much as possible the look & feel of the GNU/Linux iproute2 suite, but macOS (Darwin) is a BSD derivative, and some aspects cannot be replicated at all.
ip address show: look at protocol addresses
Implemented syntax:
ip address [ show [ dev IFNAME ] [ master DEVICE | nomaster ] [ type TYPE ] [up] ]
TYPE := { bond | bond_slave | bridge | bridge_slave | feth5 | vlan }
Shows IPv4 and IPv6 addresses assigned to all network interfaces. The ‘show’ subcommand can be omitted:
ip address show
Same as above except that only IPv6 addresses assigned to active network interfaces are shown:
ip -6 address show up
Shows IPv4 and IPv6 addresses assigned to network interface en0 in pretty printed JSON:
ip -j -p address show dev en0
Shows IPv4 only addresses assigned to networks member of bridge0:
ip -4 address show master bridge0
Shows IP addresses belonging to private C class network 192.168.0.0/24:
ip address show to 192.168.0.0/24
Note:
qdisc (queuing discipline) is part of the Linux Traffic Control subsystem (TC) managed via the tc utility. Even if this information is not reported, similar results in traffic control and shaping can be achieved using dnctl and pfctl.
address lifetime for IPv6 addresses (-L flag of ifconfig) is not provided anymore in Sonoma (macOS 14); for IPv4, addresses valid and prederred lifetime, is supposed forever (0xffffffff = 4.294.967.295 = 32 bit).
sysctl net.inet6.ip6.temppltime specifies the “preferred lifetime” for privacy addresses, in seconds, and defaults to 86400 (one day).
sysctl net.inet6.ip6.tempvltime specifies the “valid lifetime” for privacy addresses, in second, and defaults to 604800 (one week).
veth can be replaced by feth in macOS
ip address add: add new protocol address
ip address change: change protocol address
ip address replace: change or add protocol address
Implemented syntax:
ip address {add|change|replace} IFADDR dev IFNAME [ LIFETIME ] [ CONFFLAG-LIST ]
Note:
{change|replace} option “really” change address properties (e.g. broadcast) while Linux simply ignore them.
ip address delete: delete protocol address
ip link show: display device attributes
Implemented syntax:
ip link show [ DEVICE ] [ up ] [ master DEVICE | nomaster ] [ type ETYPE ]
ETYPE := [ TYPE | bridge_slave | bond_slave ]
TYPE := [ bridge | bond ]
Shows the state of all network interfaces on the system:
ip link show
Shows the bridge devices:
ip link show type bridge
Shows the vlan devices:
ip link show type vlan
Shows devices enslaved by bridge0:
ip link show master bridge0
Note:
txqlen (the transmit queue length) is not configurable on specific interface; a system default value is managed via sysctl net.link.generic.system.sndq_maxlen (or net.link.generic.system.rcvq_maxlen).
ip link add: add virtual link
Implemented syntax:
ip link add [ link DEV ] [ name ] NAME [ address LLADDR ] [ mtu MTU ] type TYPE [ ARGS ]
Create a VLAN with TAG 100 linked to en1:
ip link add link en1 name vlan100 type vlan id 100
Create a new bridge interface (auto numbering1):
ip link add type bridge
Create a new bridge with a specified name:
ip link add bridge20 type bridge
Create a new static bond (vs lacp) interface:
ip link add bond1 type bond mode active-backup
Note:
macOS ifconfig print the created interface name to the standard output
ip link delete: delete virtual link
Implemented syntax:
ip link delete { DEVICE | dev DEVICE } type TYPE [ ARGS ]
Delete any kind of virtual interface:
ip link del vlan100
ip link set (or change): change device attributes
Implemented syntax:
ip route show: list routes
Implemented syntax:
ip route [ show [ SELECTOR ] ]
SELECTOR := [ proto RTPROTO ] [ type TYPE ] [ scope SCOPE ]
TYPE := { unicast | broadcast | multicast | blackhole }
SCOPE := [ host | link | global ]
RTPROTO := [ kernel | static ]
List routes using a specific gateway:
ip route show via 192.168.0.1
List IPv6 routes using a specific network interface:
ip -6 route show dev en1
List routes for multicast:
ip route show type multicast
List availabe routes to reach specific network:
ip route show to match 192.168.1.0/24
List IPv4 and IPv6 routes2
ip route show table all
Note:
iif is not honored (is treated like dev and oif).
Route tables are not implemented in macOS (Darwin), but “table all” will result in show IPv4 + IPv6 routes
ip route add: add new route
ip route delete: delete route
ip route change: change route
ip route replace: change or add new one
Implemented syntax:
ip route { add | delete | change | replace } ROUTE
ROUTE := [ TYPE ] PREFIX [ tos TOS ] [ proto RTPROTO ] [ scope SCOPE ]
TYPE := { unicast | broadcast | multicast | blackhole }
SCOPE := [ host | link | global ]
RTPROTO := [ kernel | boot | static ]
Add direct routing on a specific network interface:
ip route add 192.168.22.0/24 dev en1
Change interface for a given route:
ip route change 192.168.22.0/24 dev en0
Replace default gateway:
ip route replace default via 192.168.0.254
Delete route:
ip route del 192.168.22.0/24
ip route get: get a single route
Implemented syntax:
ip route get ADDRESS
Shows the route to reach Google DNS 8.8.8.8:
ip route get 8.8.8.8
ip neigh show: list neighbour entries
Note:
NOARP and PERMANENT states are not catched
ip neigh flush: flush neighbour entries
Same syntax of ip neigh show
Contributing
Every contribute is welcome!
Fork the repository
Clone the fork
git clone https://github.com/YOUR-USERNAME/iproute4mac
Create a branch
Before making changes to the project, you should create a new branch and check it out (see “GitHub flow”).
git branch BRANCH-NAME
git checkout BRANCH-NAME
Create a developer environment
python3 -m venv venv
source venv/bin/activate
Then install requiered packages:
python3 -m pip install -U pip
python3 -m pip install pre-commit pytest pytest-console-scripts
pre-commit install
Coding style
Ruff is used to enforce coding style. You can checkout the compliance with the following command:
pre-commit run --all-files [--show-diff-on-failure]
Commit your work
Create as few commit as possible to make diff checking easier. In case of modification of already pushed commit, amend it if possible:
git add -A
git commit --amend
git push --force
In case of multiple and not organic commits, “Squash and merge” policy will be applied.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file iproute4mac-0.5.7.tar.gz
.
File metadata
- Download URL: iproute4mac-0.5.7.tar.gz
- Upload date:
- Size: 104.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12e55f81c322ef808886e3064fe54bebcc0b4cd5f6e3c677dfd3fb5b53563d7e |
|
MD5 | dbb22acb3b8a7a8c16e5c1192d6cc54b |
|
BLAKE2b-256 | f6bec00247d5af3d358082aa91f69c2b8848ede7286e455cf91b30d504c81860 |
File details
Details for the file iproute4mac-0.5.7-py3-none-any.whl
.
File metadata
- Download URL: iproute4mac-0.5.7-py3-none-any.whl
- Upload date:
- Size: 109.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18a7d0c85390e1c02bc0a0046a5fb637ccd5291fc6673d129064f8944f166e10 |
|
MD5 | b3976a82f4c21c69293f3dc412348dfd |
|
BLAKE2b-256 | 5398caf205b889e9e61741483fd255f38fe2860e1c3edac989b59f1d67a21f03 |