Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to bind an arbitrary port, say 1337, to a specific NIC? I have 2 NICs, one configured for IPv4, the other for IPv6. I want to ensure that whenever port 1337 is used, it goes through the IPv6 interface.

share|improve this question

I think that you can do that using iptables. A rule in IP table should do it, but I think that the NIC in question has to have a IP assigned to it. Try this, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

iptables -A PREROUTING -p tcp --dport xxxx -i eth1

Replace xxxx with the port number. For more info on iptables see the Manpage

share|improve this answer
It looks like that command would work for the IPv4 interface, but it would need to specify the table like this: iptables -t nat -A PREROUTING -p tcp --dport 10337 -i eth1 I need a solution that works for IPv6, which doesn't have a nat table. – bbbgscott Jul 16 '13 at 17:23

You usually bind a service (that uses a certain port) to an address. So when you bind your service to the IPv6 address you should be set.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.