Assigning IPv6 address to user

in flag

Is it possible to assign a different static IPv6 address to each user on the system?

cocomac avatar
cn flag
It seems that you may have [an XY Problem]( Generally each network interface gets an IP, not each user. It might be do-able if you had a NIC with multiple ports or something, but what is your goal? What are you trying to accomplish by giving each user a separate IP address?
synkro avatar
in flag
The idea is to separate each account's networking. For example, account1 is running some docker containers for a certain task, and would like to keep it separated from account2 that runs different processes. Also, account1 may connect and browse the internet under its own ipv6 address, which account2 would have its own address.
sleepyhead avatar
in flag
sleepyhead avatar
in flag
In Linux you can separate processes and networking in namespaces. Docker does this in simple ways, you can start dockers, but assigning IPv6 addresses by user without docker will be super hard. You're best of using the --ip6 flag to give each docker container its own IP address
in flag

After some digging, I found exactly what I needed, in a solution that uses iptables

So for example in my case, I would use ip6tables like this:

ip6tables -t nat -A POSTROUTING -m owner --uid-owner user1 -j SNAT --to-source 2001:db8:dead:bee1::
ip6tables -t nat -A POSTROUTING -m owner --uid-owner user2 -j SNAT --to-source 2001:db8:dead:bee2::

Then verify that user1 is indeed using the assigned IPv6 address (IPv4 or IPv6 can be forced by passing the appropiate flag to the client, e.g curl -4 or curl -6):

su user1
curl -6

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.