# Juniper Switching CLI & J-Web - A Collection

<span style="color: rgb(0, 0, 0);">This page is for the Juniper Switching CLI or J-</span><span style="color: rgb(0, 0, 0);">Web interfaces which don't all need separate pages. You can search for them with **Ctrl + F** or click the "Search" at the top.</span>

<span style="color: rgb(0, 0, 0);">**The terminology used in this documentation is listed below:**</span>  
<span style="color: rgb(0, 0, 0);">•  **Run** – Run the command and press enter. No other interaction needed. No output will appear.</span>  
<span style="color: rgb(0, 0, 0);">• **Type** – Type a word, most of the time being Boolean (yes/no, true/false).</span>

##### **<span style="color: rgb(0, 0, 0);">Configuring Virtual Chassis EX Series</span>**  


<span style="color: rgb(132, 63, 161);">***Taken from:** [https://www.juniper.net/documentation/us/en/software/junos/virtual-chassis-qfx/topics/concept/virtual-chassis-ex4200-overview.html#understanding-ex-series-virtual-chassis\_\_d2126e1405](https://www.juniper.net/documentation/us/en/software/junos/virtual-chassis-qfx/topics/concept/virtual-chassis-ex4200-overview.html#understanding-ex-series-virtual-chassis__d2126e1405)* </span>

**<span style="color: rgb(0, 0, 0);">Sadly, this takes you to a PDF and you need to use Wayback machine to get the snapshot of: </span>**  
<span style="color: rgb(0, 58, 255);">*https://web.archive.org/web/20231201042147/https://www.juniper.net/documentation/us/en/software/junos/virtual-chassis-ex-4200-4500/topics/task/virtual-chassis-ex4200-cli.html* </span>

##### **<span style="color: rgb(0, 0, 0);">Enabling J-Web Interface</span>**

<span style="color: rgb(0, 0, 0);">Connect the COM cable or use the IP address of the system and SSH to it. Login as normal.</span>

<span style="color: rgb(0, 0, 0);">Run **cli**</span>  
<span style="color: rgb(0, 0, 0);">Run **edit**</span>  
<span style="color: rgb(0, 0, 0);">Run **delete interfaces**</span>  
<span style="color: rgb(0, 0, 0);">Run **set interfaces vlan.0 family inet address 192.192.0.x**</span>  
*<span style="color: rgb(0, 0, 0);">(replacing x with the end IP for the management interface)</span>*  
<span style="color: rgb(0, 0, 0);">Run **commit**</span>  
<span style="color: rgb(0, 0, 0);">Wait for synchronization to complete.</span>

<span style="color: rgb(0, 0, 0);">**Description:** We have removed all interfaces and configured the **vlan.0** interface to **192.192.0.x**, x being the end of the switches management IP address temporarily. Without this being set, the switch will complain that no interfaces have been configured for vlan.0.</span>

<span style="color: rgb(176, 19, 243);">***Taken from:** <span style="color: rgb(176, 19, 243);">[https://supportportal.juniper.net/s/article/Interface-must-already-be-defined-under-edit-interfaces-commit-error?language=en\_US](https://supportportal.juniper.net/s/article/Interface-must-already-be-defined-under-edit-interfaces-commit-error?language=en_US) </span>*</span>

<span style="color: rgb(0, 0, 0);">Run **set interfaces vme unit 0 family inet address 192.168.0.x/&lt;subnet&gt;**</span>  
*<span style="color: rgb(0, 0, 0);">(replacing x with the IP for management interface, the vme IP)</span>*

<span style="color: rgb(0, 0, 0);">Run **set system services ssh root-login allow**</span>  
<span style="color: rgb(0, 0, 0);">Run **set system services web-management management-url 192.168.0.x/root**</span>  
*<span style="color: rgb(0, 0, 0);">(replacing x with the IP for management interface web portal, same as the vme IP set earlier)</span>*

<span style="color: rgb(0, 0, 0);">Run **set system services web-management http interface vme**</span>  
<span style="color: rgb(0, 0, 0);">Run **set system services web-management https port 443**</span>  
<span style="color: rgb(0, 0, 0);">Run **set system services web-management https system-generated-certificate**</span>  
<span style="color: rgb(0, 0, 0);">Run **set system services web-management https interface vme**</span>  
<span style="color: rgb(0, 0, 0);">Run **commit**</span>  
<span style="color: rgb(0, 0, 0);">Wait for synchronization to complete.</span>

<span style="color: rgb(0, 0, 0);">**Description:** We have updated the management interface, J-Web, to show the webpage instead of “Connection Refused”. This is believed to be happening because of it binding the interface to me0, not vme, which is the virtual chassis interface. Citation Needed.</span>

##### **<span style="color: rgb(0, 0, 0);">Switching Between Primary Master &amp; Backup Switches</span>**

<span style="color: rgb(0, 0, 0);">Connect the COM cable or use the IP address of the system and SSH to it. Login as normal.</span>  
<span style="color: rgb(176, 19, 243);">***Taken from:*** *https://www.juniper.net/documentation/us/en/software/junos/cli-reference/topics/ref/command/request-chassis-routing-engine-master.html* </span>

<span style="color: rgb(0, 0, 0);">Run **cli**</span>  
<span style="color: rgb(0, 0, 0);">Run **request chassis routing-engine master switch**</span>  
<span style="color: rgb(0, 0, 0);">Type **yes**</span>

<span style="color: rgb(0, 0, 0);">You will be disconnected after about 1-2 seconds on the switch you are connected on (either master or backup) and you will need to wait around 5 minutes before issuing this command again.</span>

##### **<span style="color: rgb(0, 0, 0);">Save Time With Making Synchronize Default</span>**  


<span style="color: rgb(0, 0, 0);">This section allows you to set the command commit to always run commit synchronize without you needing to write that word afterwards.</span>  
<span style="color: rgb(0, 0, 0);">Connect the COM cable or use the IP address of the system and SSH to it. Login as normal.</span>

<span style="color: rgb(0, 0, 0);">Run **cli**</span>  
<span style="color: rgb(0, 0, 0);">Run **edit**</span>  
<span style="color: rgb(0, 0, 0);">Run **set system commit synchronize**</span>  
<span style="color: rgb(0, 0, 0);">Run **commit synchronize**</span>

<span style="color: rgb(0, 0, 0);">On next command run of commit, it will run commit synchronize. This should be visibly apparent that it worked as you will see fpc0 and fpc1 sync along the left when committing between them when in virtual-chassis mode.</span>

##### **<span style="color: rgb(0, 0, 0);">Switching ROM On Switch</span>**

<span style="color: rgb(0, 0, 0);">Connect the COM cable to the switch you wish to switch ROM on. This is good for getting to a different firmware version if it decided to downgrade due to not being the same, configuration resync or getting back from Linecard to Master/Backup due to version issue.</span>

<span style="color: rgb(0, 0, 0);">**Note:** Due to the command **request session member X**, a COM cable isn’t required.</span>

<span style="color: rgb(0, 0, 0);">Run **request system reboot slice alternate media internal**</span>  
<span style="color: rgb(0, 0, 0);">Type **yes**</span>

<span style="color: rgb(0, 0, 0);">Wait for switch to restart. This will countdown on 60 seconds, 30 seconds and immediately, respectively.</span>

##### **<span style="color: rgb(0, 0, 0);">Syncing Current ROM With Redundant ROM</span>**

<span style="color: rgb(0, 0, 0);">SSH or connect the COM cable and run the command below to sync the current system configuration and OS version to the redundant ROM **AND** between both the fpc0 and fpc1.</span>

<span style="color: rgb(0, 0, 0);">Run **cli**</span>  
<span style="color: rgb(0, 0, 0);">Run **edit**</span>  
<span style="color: rgb(0, 0, 0);">Run **run request system snapshot slice alternate**</span>

##### **<span style="color: rgb(0, 0, 0);">Get Full System Info From Both Switches (Virtual Chassis)</span>**

<span style="color: rgb(0, 0, 0);">Obtain the system information from both switches such as the state, temperature, memory and CPU usage, model, serial number and last reboot reason. </span>

<span style="color: rgb(0, 0, 0);">Run **cli**</span>  
<span style="color: rgb(0, 0, 0);">Run **show chassis routing-engine**</span>

##### **<span style="color: rgb(0, 0, 0);">Login To Alternative Switch In CLI Mode For Logs/Configuration</span>**

<span style="color: rgb(0, 0, 0);">To get into an additional member of the virtual chassis, you can run the below command to access it instead of running the switch routing-engine command. For example, member 0 is top switch, member 1 is bottom switch if running in a 2 system virtual-chassis. Replace X with the switch member number. For locating the number, you can Run show virtual-chassis to view member numbers.  
</span>

<span style="color: rgb(0, 0, 0);">Run **cli**</span>  
<span style="color: rgb(0, 0, 0);">Run **request session member x**</span>

##### <span style="color: rgb(0, 0, 0);">**Enabling SNMP v3 on Juniper 4200/4500 switches**</span>  


```markdown
set snmp v3 vacm security-to-group security-model usm security-name <USERNAME> group read-only-group
set snmp v3 vacm access group read-only-group default-context-prefix security-model usm security-level privacy read-view read-only-view
commit comment "Preparation For SNMPv3"

set snmp v3 usm local-engine user <USERNAME> authentication-sha authentication-password "<CRYPTO_PASSWORD>"
set snmp v3 usm local-engine user <USERNAME> privacy-aes128 privacy-password "<PASSWORD>"
set snmp view read-only-view oid .1 include
show snmp
commit comment "Setup SNMPv3 For <APPLICATION>"
```

<p class="callout info"><span style="color: rgb(0, 0, 0);">For TenantOS, the settings to select are below:  
  
![](https://jasmeow.pics/NvnjOC.png)  
</span></p>

##### **<span style="color: rgb(0, 0, 0);">Setup Syslog to an endpoint IP listening for Syslog data</span>**  


```markdown
set system syslog host <IP> any any
set system syslog file messages any any
commit comment "Activate Syslog Data Collection"
```

##### <span style="color: #000000;">**Installing LLDPD to get data from the port connected and query the switch**</span>

<span style="color: rgb(0, 0, 0);">Using this will tell you all the connection information from the switch, such as what port, what the switch name is, vlans it's providing to you, etc.</span>  
  
<span style="color: rgb(0, 0, 0);">apt install lldpd -y &amp;&amp; /</span>  
<span style="color: rgb(0, 0, 0);">lldpctl  
</span>

##### <span style="color: #000000;">**Need to rename a VLAN on the switch and need to find out which members are in that VLAN so you can delete it safely?** </span>

<span style="color: #000000;">This can also be used to prepare who has duplicate VLAN names such as "ClientVlan" and "Vlan.3" basically meaning, it has the named version of vlan 3 and the numerical version. Running this command helps you clear out those "named vlan" problems which originate by making the vlans on the JWeb interface before being comfortable with CLI. This will then give you the chance to rename a vlan later on with rename vlan command, etc.</span>

```markdown
cli -c "show configuration interfaces | display set" | grep "family ethernet-switching vlan members <VLAN>" | awk '{print "delete", $2, $3, $4, $5, $6, $7, "vlan members <VLAN>"}' > /var/tmp/<VLAN>.conf

```

<span style="color: #000000;">  
</span>