Netsh interface ipv4 add route синтаксическая ошибка

On a windows7 machine I was trying to set the standard gateway following this example:

netsh.exe interface ipv4 set route 0.0.0.0/32 "Internet" 172.16.5.1

which returned the following error:

The filename, directory name, or volume label syntax is incorrect

Why is that the case, and how can I fix set the standard gateway for my connections?

Community's user avatar

asked Jul 22, 2014 at 12:05

Alex's user avatar

3

You need to use your real interface’s name instead of "Internet". You can list them with netsh interface show interface.

answered Jul 22, 2014 at 12:28

piernov's user avatar

piernovpiernov

2,00614 silver badges18 bronze badges

There’s some kind of an «underlying name» to the interface, set up on its 1st creation, or when it’s manually changed. You can get it using:

netsh interface ipv4 show config

It might be different from what you see in the GUI window or from running netsh interface show interface

Try using that interface name instead — this worked for me on windows 7.

answered Oct 4, 2019 at 17:50

mork's user avatar

morkmork

1312 bronze badges

I just had a similar same issue. The problem was the » character. I copied the netsh from a word document I got from our software vendor and pasted that directly into the CMD and changed the needed parts which failed with the error mentioned here. However when I copied the string at first to notepad and replaced one from the » I discovered that they are different, so I replaced both / re-typed both and the issue is solved now.

answered Aug 7, 2015 at 9:13

BastianW's user avatar

BastianWBastianW

6694 silver badges11 bronze badges

Apparently on Windows 7, you need to use a different syntax to execute the command in the correct context. Preface the context specifiers interface ipv4 with a -c parameter and quote the entire context specifier. For example, to set the adapter to DHCP:

netsh -c "interface ipv4" set address name="Local Area Connection" source=dhcp

answered Mar 13, 2015 at 16:13

Jeff's user avatar

на машине windows7 я пытался установить стандартный шлюз после этой пример:

netsh.exe interface ipv4 set route 0.0.0.0/32 "Internet" 172.16.5.1

, который вернул следующую ошибку:

The filename, directory name, or volume label syntax is incorrect

почему это так, и как я могу исправить установить стандартный шлюз для моих соединений?

3 ответа

вам нужно использовать имя вашего реального интерфейса вместо "Internet". Вы можете перечислить их с netsh interface show interface.

1

отвечен piernov 2022-12-05 19:14

У меня просто была аналогичная проблема. Проблема была в «характере». Я скопировал netsh из документа word, который я получил от нашего поставщика программного обеспечения, и вставил его непосредственно в CMD и изменил необходимые части, которые потерпели неудачу с ошибкой, упомянутой здесь. Однако, когда я сначала скопировал строку в блокнот и заменил ее из » я обнаружил, что они разные, поэтому я заменил оба / re-typed оба, и проблема решена сейчас.

1

отвечен BastianW 2022-12-05 21:31

видимо на Windows 7, вам нужно использовать другой синтаксис для выполнения команды в правильном контексте. Предисловие спецификаторов контекста интерфейс ipv4 С — c параметр и цитировать весь спецификатор контекста. Например, чтобы установить адаптер на DHCP:

netsh -c "interface ipv4" set address name="Local Area Connection" source=dhcp

0

отвечен Jeff 2022-12-05 23:48

На компьютере с Windows7 я пытался установить стандартный шлюз, следуя этому примеру:

netsh.exe interface ipv4 set route 0.0.0.0/32 "Internet" 172.16.5.1

который вернул следующую ошибку:

The filename, directory name, or volume label syntax is incorrect

Почему это так, и как я могу установить стандартный шлюз для моих соединений?

2014-07-22 12:05

3
ответа

В интерфейсе есть какое-то «базовое имя», настроенное при его первом создании или когда оно изменяется вручную. Вы можете получить это используя:

netsh interface ipv4 show config

Это может отличаться от того, что вы видите в окне графического интерфейса или от запуска netsh interface show interface

Попробуйте вместо этого использовать это имя интерфейса — это работает для меня на Windows 7.


mork

04 окт ’19 в 20:50
2019-10-04 20:50

2019-10-04 20:50

Вам нужно использовать имя вашего реального интерфейса вместо "Internet", Вы можете перечислить их с netsh interface show interface,


piernov

22 июл ’14 в 12:28
2014-07-22 12:28

2014-07-22 12:28

У меня просто была похожая проблема. Проблема заключалась в «символе». Я скопировал netsh из текстового документа, который я получил от нашего поставщика программного обеспечения, и вставил его непосредственно в CMD и изменил необходимые детали, что не удалось с упомянутой здесь ошибкой. Однако, когда я сначала скопировал строку в Блокнот и заменил один из «Я обнаружил, что они разные, поэтому я заменил оба / повторно набрал оба, и проблема решена сейчас.


BastianW

07 авг ’15 в 09:13
2015-08-07 09:13

2015-08-07 09:13

Очевидно, в Windows 7 вам нужно использовать другой синтаксис для выполнения команды в правильном контексте. Предисловие спецификаторов контекста связывает интерфейс ipv4 с параметром -c и заключает в кавычки весь спецификатор контекста. Например, чтобы установить адаптер на DHCP:

netsh -c "interface ipv4" set address name="Local Area Connection" source=dhcp


Jeff

13 мар ’15 в 16:13
2015-03-13 16:13

2015-03-13 16:13

Hey Spicehead,

I’m in need of some assistance for what I thought was an easy task but I can’t seem to figure out.

I have Windows Server 2012 with (2) Network Cards.

NIC #1 — «Local Network»

IP: 192.168.2.X
Subnet: 255.255.255.0
Gateway: 192.168.2.1

NIC #2 — «Backup Network»

IP: 172.16.100.2
Subnet: 255.255.255.240
Gateway: 172.16.100.1

Both gateways plug into different ports on my SonicWall. The networks can talk with each other but the main reason I want to route traffic out a specific NIC is so my backups to a separate facility can be all gigabit connections. There is a VPN tunnel (which is up) and routes to 172.16.200.1 (assigned to port on different SonicWall).

I’ve added the following command but traffic for the 172.16.200.0/28 network is still routing out the NIC #1 because I even have NIC #2 unplugged and still getting ping responses. 

Command Added:

netsh interface ipv4 add route 172.16.200.0/28 «Backup Network» 172.16.100.2 store=persistent

Image: post content

  • Remove From My Forums
  • Question

  • Hello,

    When i configure vpn l2tp (via profile made by cmak) in w7 i ‘add route …’ from hand using interface ID, i.e.:

    netsh interface ipv4 add route prefix=10.10.0.0/16 interface=62

    62 is interface my vpn l2tp connection. everything is fine but …. when i add i.e. gsm modem like orange business everywhere interface id of my vpn l2tp is changed — in my case is 62 because 62 is for gsm modem. futhermore .. if user change modem for
    another the interface ID change again .. and my rout is invalid.

    users can not change route table. i do not wand give them more permissions than user. 

    is it possible to configure vpn l2tp interface for fixed interface ID? or how to change route according to current interface id of vpn l2tp interface?


    Voytas

Answers

  • We may refer the following article.

    Netsh commands for Interface Internet Protocol version 4 (IPv4)

    I think you concern about the “metric” of routes but not “interface”. Please chang the “interface” to “metric” and let us know the result.

    Arthur Xie
    TechNet Subscriber Support in forum 

    If you have any feedback on our support, please contact
    tngfb@microsoft.com.


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”

    • Edited by

      Thursday, August 26, 2010 2:26 AM

    • Marked as answer by
      Arthur Xie
      Monday, August 30, 2010 3:42 AM

  • According to the article, you can specify the value of the parameters “interface”. 

    Syntax
    add route [prefix=]IP4Address/Integer [[interface=]String] [[nexthop=]IPv4Address] [[siteprefixlength=]Integer] [[metric=]Integer] [[validlifetime=]{Integer | infinite}] [[preferredlifetime=]{Integer | infinite}] [[store=]{active | persistent}]

    In command line, after entering “route print”, you will see the route table. From here we will know the information of existed routes, including their network destinations, net masks, gateways, interfaces and metrics.


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”

    • Marked as answer by
      Arthur Xie
      Monday, August 30, 2010 3:42 AM

  • Netlogon 5774 ошибка при динамической регистрации записи
  • Netlify page not found ошибка
  • Netflix ошибка tvq pb101
  • Netflix ошибка 113 apple tv
  • Netflix код ошибки ui 800 3