Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Docker container with exposed port on user defined network sees NAT IP address

Featured Replies

Experencing an issue where docker containers with exposed ports do not see the true client IP address, but instead see the gateway IP address of a given docker network when receiving packets.

 

To demonstrate, I've got a setup with 3 machines:

 

* A windows machine acting as the client on 192.168.1.228

* An unraid machine on 192.168.1.2

* An ubuntu machine on 192.168.1.243

 

I create a user-defined network with the bridge driver.

On the ubuntu machine, when packets come in to containers the IP address on the packet is seen as the expected 192.168.1.228

But on the unraid machine, when packets come in to containers the IP address on the packet is seen as the gateway for the user defined network, in this case 172.17.0.1

 

Netcat within the swag image is used to demonstrate:

 

On the ubuntu machine, run netcat listening on port 9000 then connect from the windows machine.

Here we can see that the remote address is seen as 192.168.1.228

 

user@ubuntu:~$ docker run --rm -it --network mynet -p 9000:9000 --entrypoint /usr/bin/nc lscr.io/linuxserver/swag:latest -lv 9000
Listening on 0.0.0.0 9000
Connection received on 192.168.1.228 63218

 

On the unraid machine, run netcat listening on port 9000 then connect from the windows machine.

Here we can see that the remote address is seen as 172.17.0.1:

 

root@unraid:~# docker run --rm -it --network mynet -p 9000:9000 --entrypoint /usr/bin/nc lscr.io/linuxserver/swag:latest -lv 9000
Listening on 0.0.0.0 9000
Connection received on 172.17.0.1 63278

 

What settings do I need to change so that a container with forwarded ports on a user defined bridge network will see the actual remote client IP address and not the NAT'd docker gateway address?

 

Edited by dfill

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.