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 change ip addr to new ip addr, but subnet broadcast address no change, in macos m1 #68

Open
flyzxt opened this issue Sep 13, 2023 · 1 comment

Comments

@flyzxt
Copy link

flyzxt commented Sep 13, 2023

os: macos m1

let mut tun_config = tun::Configuration::default();
tun_config.address((10, 0, 0, 1)).netmask((255, 255, 255, 0)).up();

when use default code to create tun device, system route table like blow:

# netstat -nr -f inet
Routing tables

Internet:
Destination        Gateway            Flags               Netif Expire
10.0.0.255         10.0.0.1           UH                 utun14

change address in code, and re run

let mut tun_config = tun::Configuration::default();
tun_config.address((10, 0, 1, 1)).netmask((255, 255, 255, 0)).up();
# netstat -nr -f inet
Routing tables

Internet:
Destination        Gateway            Flags               Netif Expire
10.0.0.255         10.0.1.1           UH                 utun14

I think corret route table is 10.0.1.255, but it's not change.

@M0dEx
Copy link

M0dEx commented Dec 17, 2023

Hi @flyzxt!

For the destination to change, you must call the destination() setter with the desired address on the tun_config:

tun_config
    .address((10, 0, 1, 1))
    .destination((10, 0, 1, 255))
    .netmask((255, 255, 255, 0))
    .up();

Be wary of this on Windows, however, as it override the default gateway.

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