linux:netns
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| linux:netns [2025/08/15 16:33] – jonathan | linux:netns [2025/08/15 16:55] (current) – jonathan | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ===== Linux - NETNS ===== | ===== Linux - NETNS ===== | ||
| + | This Bash script creates three separate Linux network namespaces (instance1, instance2, and instance3), assigns a specific physical interface to each, configures their IPv4/IPv6 addresses and default routes, and sets custom DNS resolvers for each namespace. | ||
| <code - / | <code - / | ||
| #!/bin/bash | #!/bin/bash | ||
| Line 34: | Line 34: | ||
| echo -e " | echo -e " | ||
| </ | </ | ||
| + | \\ | ||
| + | This Bash script displays the network interface details, IPv4/IPv6 addresses, and routing tables for three network namespaces (instance1, instance2, and instance3) in a formatted, sectioned output. | ||
| <code - show-netns-settings.sh> | <code - show-netns-settings.sh> | ||
| #!/bin/bash | #!/bin/bash | ||
| Line 76: | Line 77: | ||
| echo "################################################" | echo "################################################" | ||
| </ | </ | ||
| + | \\ | ||
| + | This script opens firefox-esr in three different network namespaces (instance1, instance2, instance3), each using its own browser profile and with proxy settings disabled. | ||
| <code - netns-firefox.sh> | <code - netns-firefox.sh> | ||
| #####Note that it isn't compatible with Firefox snap version. The firefox-esr must be installed.##### | #####Note that it isn't compatible with Firefox snap version. The firefox-esr must be installed.##### | ||
| Line 91: | Line 93: | ||
| env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY firefox-esr --new-instance --profile $HOME/ | env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY firefox-esr --new-instance --profile $HOME/ | ||
| </ | </ | ||
| + | \\ | ||
| + | This script runs speedtest-cli inside three network namespaces (instance1, instance2, instance3) with proxy variables cleared, allowing separate network speed tests for each namespace. | ||
| <code - netns-speedtest.sh> | <code - netns-speedtest.sh> | ||
| #!/bin/bash | #!/bin/bash | ||
| Line 103: | Line 106: | ||
| sudo -u $USER \ speedtest-cli | sudo -u $USER \ speedtest-cli | ||
| </ | </ | ||
| + | \\ | ||
| + | This systemd unit file defines a one-shot service that runs the / | ||
| <code - / | <code - / | ||
| [Unit] | [Unit] | ||
| Line 117: | Line 121: | ||
| WantedBy=multi-user.target | WantedBy=multi-user.target | ||
| </ | </ | ||
| + | \\ | ||
| + | These commands reload systemd to recognize new or changed units, enable the instances-netns.service to start at boot, and start the service immediately. | ||
| <code - Activate the new service> | <code - Activate the new service> | ||
| sudo systemctl daemon-reload | sudo systemctl daemon-reload | ||
linux/netns.txt · Last modified: by jonathan
