# How can I let the dns wlan0 dhcpcd gened prior to eth0?

## leiking

```

➜  ~ git:(master) ✗ cat /etc/resolv.conf 

# Generated by dhcpcd from eth0, wlan0

# /etc/resolv.conf.head can replace this line

nameserver 10.128.1.9

nameserver 10.128.1.10

nameserver 10.30.1.9

nameserver 10.30.1.10

nameserver 202.99.96.68

nameserver 202.99.104.68

# /etc/resolv.conf.tail can replace this line

```

```

modules="wpa_supplicant"

metric_wlan0="10"

metric_eth0="100"

config_wlan0="dhcp"

wpa_supplicant_wlan0="-Dwext"

```

```

➜  ~ git:(master) ✗ route -n

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0         117.13.141.1    0.0.0.0         UG    10     0        0 wlan0

0.0.0.0         10.86.34.1      0.0.0.0         UG    100    0        0 eth0

10.86.34.0      0.0.0.0         255.255.255.192 U     100    0        0 eth0

117.13.141.0    0.0.0.0         255.255.255.0   U     10     0        0 wlan0

127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo

```

```

➜  ~ git:(master) ✗ ifconfig

eth0      Link encap:Ethernet  HWaddr e8:11:32:01:aa:5d  

          inet addr:10.86.34.19  Bcast:10.86.34.63  Mask:255.255.255.192

          inet6 addr: fe80::ea11:32ff:fe01:aa5d/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:1655 errors:0 dropped:42 overruns:0 frame:0

          TX packets:32 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:112595 (109.9 KiB)  TX bytes:2224 (2.1 KiB)

          Interrupt:19 

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:36 errors:0 dropped:0 overruns:0 frame:0

          TX packets:36 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:2304 (2.2 KiB)  TX bytes:2304 (2.2 KiB)

wlan0     Link encap:Ethernet  HWaddr 18:f4:6a:cb:ba:1e  

          inet addr:117.13.141.83  Bcast:117.13.141.255  Mask:255.255.255.0

          inet6 addr: fe80::1af4:6aff:fecb:ba1e/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:1629 errors:0 dropped:0 overruns:0 frame:0

          TX packets:2777 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:939793 (917.7 KiB)  TX bytes:441284 (430.9 KiB)

```

```

➜  ~ git:(master) ✗ rc-update

            alsasound | boot                         

             bootmisc | boot                         

             cpufreqd |      default                 

                 dbus |      default                 

                devfs |                       sysinit

                dmesg |                       sysinit

                 fsck | boot                         

             gentoo32 |      default                 

             hostname | boot                         

              hwclock | boot                         

              keymaps | boot                         

            killprocs |              shutdown        

          laptop_mode |      default                 

                local |      default                 

           localmount | boot                         

              modules | boot                         

             mount-ro |              shutdown        

                 mtab | boot                         

             net.eth0 |      default                 

               net.lo | boot                         

            net.wlan0 | boot                         

             netmount |      default                 

               procfs | boot                         

                 root | boot                         

            savecache |              shutdown        

                 swap | boot                         

               sysctl | boot                         

            syslog-ng |      default                 

         termencoding | boot                         

                 udev |                       sysinit

       udev-postmount |      default                 

              urandom | boot            

```

eth0 generated:

nameserver 10.30.1.9

nameserver 10.30.1.10

nameserver 202.99.96.68

nameserver 202.99.104.68

wlan0 generated:

nameserver 202.99.96.68

nameserver 202.99.104.68

I want this sequence:

nameserver 202.99.96.68

nameserver 202.99.104.68

nameserver 10.30.1.9

nameserver 10.30.1.10

nameserver 202.99.96.68

nameserver 202.99.104.68

I think, If i donot use openrc, only using dhcpcd. It is OK.

But if I use openrc. It failed.

Wait for expert (GAO SHOU)

----------

## khayyam

leiking ...

If I understand your question correctly, simply have dhcp not request DNS and supply the list of DNS servers to query:

```
dhcp="nodns"

dns_servers="202.99.96.68 202.99.104.68 10.30.1.9 10.30.1.10"
```

HTH & best ...

khay (电脑高手)

----------

## leiking

 *khayyam wrote:*   

> leiking ...
> 
> If I understand your question correctly, simply have dhcp not request DNS and supply the list of DNS servers to query:
> 
> ```
> ...

 

@khay. 

No. the dns is generated automatelly by dhcp. So static method is wrong.

I need the wlan's dns prior to the eth's dns

thanks!!

----------

## Halahad

 *leiking wrote:*   

> 
> 
> No. the dns is generated automatelly by dhcp. So static method is wrong.
> 
> I need the wlan's dns prior to the eth's dns
> ...

 

Why not using some public dns service? like google's 8.8.8.8 / 8.8.4.4 or opendns?

----------

## khayyam

 *leiking wrote:*   

> No. the dns is generated automatelly by dhcp. So static method is wrong. I need the wlan's dns prior to the eth's dns

 

lieking ... well, wlan0's DNS is written after because it's run after (${IFACE} are run in lexical order), so you either need to change the order in which ${IFACE} is run, statically asign DNS, or re-order /etc/resolv.conf subsequently to DNS being asigned.

I can't really see a reason for having both interfaces active, so your problem may simply be choosing to run both rather than have them managed by 'plug'.

So, assuming that there is some reason for having both interfaces active, one tentative solution would be to remove net.eth0 from default and have it run by local.d which runs after the services in default, and so after net.wlan0.

There may be cases when one or other interfaces may not get assigned IP/DNS/etc and so we can't count on the content of /etc/resolv.conf, but the list of nameservers could be reversed (prehaps as part of a postup() function).

```
awk '/nameserver/{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--]}' /etc/resolv.conf
```

Again, I think the simplist solution here is using 'plug' ... other solutions might work but as its non-standard will require some hacking.

HTH & best ...

khay

----------

