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

IP Conflict #3

Open
geidien opened this issue Oct 4, 2023 · 2 comments
Open

IP Conflict #3

geidien opened this issue Oct 4, 2023 · 2 comments

Comments

@geidien
Copy link

geidien commented Oct 4, 2023

I have a question about the eth-ap-nat, which may or may not be my actual problem. I am using your code to implement an ethernet port at L3. But, the ethernet port is being assigned the same ip address that the esp32 is being assigned when connecting. Is that related to this _g_esp_netif_soft_ap_ip in the code. It seems this is potentially where I would set the ip address statically if I wanted to for the ethernet. So I am curious how that plays into the code below and what changes I can make to keep from having conflicting IP's.

Console Output from esp_netif_lwip.c file (giving the same ip as my esp32 sta has):
I (27919) esp_netif_lwip: DHCP server assigned IP to a station, IP is: 192.168.4.2

const esp_netif_inherent_config_t eth_behav_cfg = {
.get_ip_event = IP_EVENT_ETH_GOT_IP,
.lost_ip_event = 0,
.flags = ESP_NETIF_DHCP_SERVER | ESP_NETIF_FLAG_AUTOUP,
.ip_info = (esp_netif_ip_info_t*)& _g_esp_netif_soft_ap_ip,
.if_key = "ETH_DHCPS",
.if_desc = "eth",
.route_prio = 50
};

For reference, it is hit or miss and I have had moments where the ethernet is assigned an IP that is not the same as the esp32 and it works great, but when it restarts it will get the same ip and the ethernet loses connectivity.

@david-cermak
Copy link
Owner

you can setup a different IP range, e.g.

const esp_netif_ip_info_t my_ip_range = {
        .ip = { .addr = ESP_IP4TOADDR( 192, 168, 11, 1) },
        .gw = { .addr = ESP_IP4TOADDR( 192, 168, 11, 1) },
        .netmask = { .addr = ESP_IP4TOADDR( 255, 255, 255, 0) },
};

and use this in your configuration:

const esp_netif_inherent_config_t eth_behav_cfg = {
...
.ip_info = (esp_netif_ip_info_t*)& my_ip_range,
...
};

@geidien
Copy link
Author

geidien commented Oct 4, 2023

Awesome response time, and thank you for helping! Trying to teach myself alot of this stuff, and it really helps to have transparent answers!!!!! I will give this a try!

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