Results 1 to 3 of 3

Thread: Interface with multiple IP's

  1. #1
    Join Date
    Mar 2019
    Beans
    21

    Interface with multiple IP's

    Hello,

    I have an Ubuntu 18.04 server which has an interface with two public ips (x and y).

    I have a specific external public address that i need to communicate with, but only from ip address x.

    How do i specify that only ip x can talk to this external ip?

    Thanks

  2. #2
    Join Date
    Nov 2007
    Location
    London, England
    Beans
    6,931
    Distro
    Xubuntu 19.10 Eoan Ermine

    Re: Interface with multiple IP's

    If x and y are in two different network ranges then just adding a route to the external address via a gateway that is a network neighbour to x should be enough (I think).

    Or this command should work (it's not permanent after a reboot)
    Code:
    sudo ip route add $external_address via $gateway src $x_address
    It's down to you to make sure the return path works, i.e. the external address has a working route back to x. If you pass any NAT routers then the outward and return routes must follow the same path.

  3. #3
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    14,823
    Distro
    Kubuntu 19.10 Eoan Ermine

    Re: Interface with multiple IP's

    You could also use an iptables OUTPUT rule. Suppose you want to communicate with 10.10.10.10 only from 192.168.1.1. Then you'd have these rules
    Code:
    sudo iptables -A OUTPUT -d 10.10.10.10 -s 192.168.1.1 -j ACCEPT
    sudo iptables -A OUTPUT -d 10.10.10.10 -j REJECT
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •