Skip to main content
Source Link
Creek
  • 5.2k
  • 1
  • 26
  • 34

The DHCP settings shouldn't contain a gateway address in /etc/network/interfaces. To configure DHCP on eth0, for example, you only need the following lines at a bare minimum:

auto eth0
    iface eth0 inet dhcp

Once that's configured properly ifup & ifdown should work correctly, then you can put any scripts you want ran when changing an interface's state in /etc/network/if-up.d & /etc/network/if-down.d. However, if your DHCP server is setup correctly it should provide a DNS configuration to it's clients, so configuring it by hand shouldn't be necessary

EDIT

To have your DNS settings change automatically you need to add the necessary configuration to each respective interface in /etc/network/interfaces, even if the interface uses DHCP.
DNS settings in /etc/network/interfaces are passed to resolvconf when ifup & ifdown are called by using hook scripts in the /etc/network/if-(up|down).d directory.

When you bring up an interface using ifup it's DNS settings are appended to /etc/resolv.conf, which is what you're experiencing. Conversly, the same settings are removed when the interface is torn down using ifdown. But even if you use ifdown, if there are no static DNS settings in /etc/network/interfaces then the settings for that interface not be removed from /etc/resolv.conf.

So your entry for eth1 should look like:

auto eth1    
    iface eth1 inet dhcp  #assigns an address in the 192.168.0.0/24 space with 192.168.0.1 as DNS
    metric 200            #without this line I get RNETLINK answers: file does not exist
    dns-search cable.provider.com

Additionally, you can use the -v option with ifup & ifdown to enable verbose output and see exactly what hook scripts are being executed.

Sources: man resolvconf man interfaces

The DHCP settings shouldn't contain a gateway address in /etc/network/interfaces. To configure DHCP on eth0, for example, you only need the following lines at a bare minimum:

auto eth0
    iface eth0 inet dhcp

Once that's configured properly ifup & ifdown should work correctly, then you can put any scripts you want ran when changing an interface's state in /etc/network/if-up.d & /etc/network/if-down.d. However, if your DHCP server is setup correctly it should provide a DNS configuration to it's clients, so configuring it by hand shouldn't be necessary

The DHCP settings shouldn't contain a gateway address in /etc/network/interfaces. To configure DHCP on eth0, for example, you only need the following lines at a bare minimum:

auto eth0
    iface eth0 inet dhcp

Once that's configured properly ifup & ifdown should work correctly, then you can put any scripts you want ran when changing an interface's state in /etc/network/if-up.d & /etc/network/if-down.d. However, if your DHCP server is setup correctly it should provide a DNS configuration to it's clients, so configuring it by hand shouldn't be necessary

EDIT

To have your DNS settings change automatically you need to add the necessary configuration to each respective interface in /etc/network/interfaces, even if the interface uses DHCP.
DNS settings in /etc/network/interfaces are passed to resolvconf when ifup & ifdown are called by using hook scripts in the /etc/network/if-(up|down).d directory.

When you bring up an interface using ifup it's DNS settings are appended to /etc/resolv.conf, which is what you're experiencing. Conversly, the same settings are removed when the interface is torn down using ifdown. But even if you use ifdown, if there are no static DNS settings in /etc/network/interfaces then the settings for that interface not be removed from /etc/resolv.conf.

So your entry for eth1 should look like:

auto eth1    
    iface eth1 inet dhcp  #assigns an address in the 192.168.0.0/24 space with 192.168.0.1 as DNS
    metric 200            #without this line I get RNETLINK answers: file does not exist
    dns-search cable.provider.com

Additionally, you can use the -v option with ifup & ifdown to enable verbose output and see exactly what hook scripts are being executed.

Sources: man resolvconf man interfaces

edited body
Source Link
Creek
  • 5.2k
  • 1
  • 26
  • 34

The dhcpDHCP settings shouldn't contain a gateway address in '/etc/network/interfaces'/etc/network/interfaces. To configure dhcpDHCP on eth0, for example, you only need the following lines at a bare minimum:

auto eth0
    iface eth0 inet dhcp

Once that's configured properly 'ifup'ifup & 'ifdown'ifdown should work correctly, then you can put any scripts you want to runran when changing an interface's state in '/etc/network/if-up.d'/etc/network/if-up.d & '/etc/network/if-down.d'/etc/network/if-down.d. However, if your dhcpDHCP server is setup correctly it should provide a DNS configuration to it's clients, so configuring it by hand shouldn't be necessary

The dhcp settings shouldn't contain a gateway address in '/etc/network/interfaces'. To configure dhcp on eth0, for example, you only need the following lines at a bare minimum:

auto eth0
    iface eth0 inet dhcp

Once that's configured properly 'ifup' & 'ifdown' should work correctly, then you can put any scripts you want to run when changing an interface's state in '/etc/network/if-up.d' & '/etc/network/if-down.d'. However, if your dhcp server is setup correctly it should provide a DNS configuration to it's clients, so configuring it by hand shouldn't be necessary

The DHCP settings shouldn't contain a gateway address in /etc/network/interfaces. To configure DHCP on eth0, for example, you only need the following lines at a bare minimum:

auto eth0
    iface eth0 inet dhcp

Once that's configured properly ifup & ifdown should work correctly, then you can put any scripts you want ran when changing an interface's state in /etc/network/if-up.d & /etc/network/if-down.d. However, if your DHCP server is setup correctly it should provide a DNS configuration to it's clients, so configuring it by hand shouldn't be necessary

Source Link
Creek
  • 5.2k
  • 1
  • 26
  • 34

The dhcp settings shouldn't contain a gateway address in '/etc/network/interfaces'. To configure dhcp on eth0, for example, you only need the following lines at a bare minimum:

auto eth0
    iface eth0 inet dhcp

Once that's configured properly 'ifup' & 'ifdown' should work correctly, then you can put any scripts you want to run when changing an interface's state in '/etc/network/if-up.d' & '/etc/network/if-down.d'. However, if your dhcp server is setup correctly it should provide a DNS configuration to it's clients, so configuring it by hand shouldn't be necessary